mirror of
https://github.com/plashchynski/crono.git
synced 2026-07-10 23:02:44 +02:00
Add Period#description
This commit is contained in:
@@ -10,6 +10,12 @@ module Crono
|
|||||||
@period.since(since).change({hour: @at_hour, min: @at_min}.compact)
|
@period.since(since).change({hour: @at_hour, min: @at_min}.compact)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
desc = "every #{@period.inspect}"
|
||||||
|
desc += " at #{@at_hour}:#{@at_min}" if @at_hour && @at_min
|
||||||
|
desc
|
||||||
|
end
|
||||||
|
|
||||||
def parse_at(at)
|
def parse_at(at)
|
||||||
case at
|
case at
|
||||||
when String
|
when String
|
||||||
|
|||||||
@@ -7,6 +7,13 @@ describe Crono::Period do
|
|||||||
end
|
end
|
||||||
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
|
describe "#next" do
|
||||||
context "in daily basis" do
|
context "in daily basis" do
|
||||||
it "should return the time 2 days from now" do
|
it "should return the time 2 days from now" do
|
||||||
|
|||||||
Reference in New Issue
Block a user