Class: Clasrip::DatesBetween
- Inherits:
-
Object
- Object
- Clasrip::DatesBetween
- Defined in:
- lib/clasrip.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#month ⇒ Object
Returns the value of attribute month.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(start, finish) ⇒ DatesBetween
constructor
A new instance of DatesBetween.
- #next ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(start, finish) ⇒ DatesBetween
Returns a new instance of DatesBetween.
20 21 22 23 24 25 |
# File 'lib/clasrip.rb', line 20 def initialize(start, finish) @day = 0 @year = start @finish = finish @month = 0 end |
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
18 19 20 |
# File 'lib/clasrip.rb', line 18 def day @day end |
#month ⇒ Object
Returns the value of attribute month.
18 19 20 |
# File 'lib/clasrip.rb', line 18 def month @month end |
#year ⇒ Object
Returns the value of attribute year.
18 19 20 |
# File 'lib/clasrip.rb', line 18 def year @year end |
Instance Method Details
#each ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/clasrip.rb', line 48 def each loop do yield self.next end rescue StopIteration self end |
#next ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/clasrip.rb', line 31 def next raise StopIteration if @year >= @finish if @day >= 1 and @day < 15 @day = 15 else @month += 1 @day = 1 end if @month > 12 @month = 1 @year += 1 end to_s end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/clasrip.rb', line 27 def to_s "#{@day}/#{@month}/#{@year}" end |