Add Period#description

This commit is contained in:
Dzmitry Plashchynski
2015-03-05 13:47:11 +02:00
parent 527f4768bc
commit 5b66e9049b
2 changed files with 13 additions and 0 deletions

View File

@@ -10,6 +10,12 @@ module Crono
@period.since(since).change({hour: @at_hour, min: @at_min}.compact)
end
def description
desc = "every #{@period.inspect}"
desc += " at #{@at_hour}:#{@at_min}" if @at_hour && @at_min
desc
end
def parse_at(at)
case at
when String

View File

@@ -7,6 +7,13 @@ describe Crono::Period do
end
end
describe "#description" do
it "should return period description" do
@period = Crono::Period.new(2.day, at: "15:20")
expect(@period.description).to be_eql("every 2 days at 15:20")
end
end
describe "#next" do
context "in daily basis" do
it "should return the time 2 days from now" do