Class: MonthPeriod
- Inherits:
-
Object
- Object
- MonthPeriod
- Defined in:
- lib/month_period.rb
Instance Attribute Summary collapse
-
#finish ⇒ Object
readonly
Returns the value of attribute finish.
-
#month ⇒ Object
readonly
Returns the value of attribute month.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(month:, year:) ⇒ MonthPeriod
constructor
A new instance of MonthPeriod.
- #to_range ⇒ Object
Constructor Details
#initialize(month:, year:) ⇒ MonthPeriod
Returns a new instance of MonthPeriod.
6 7 8 9 10 11 |
# File 'lib/month_period.rb', line 6 def initialize(month:, year:) @month = month @year = year @start = Time.new(year, month, 1, 0, 0, 0) @finish = start.end_of_month.end_of_day end |
Instance Attribute Details
#finish ⇒ Object (readonly)
Returns the value of attribute finish.
4 5 6 |
# File 'lib/month_period.rb', line 4 def finish @finish end |
#month ⇒ Object (readonly)
Returns the value of attribute month.
4 5 6 |
# File 'lib/month_period.rb', line 4 def month @month end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
4 5 6 |
# File 'lib/month_period.rb', line 4 def start @start end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/month_period.rb', line 4 def year @year end |
Instance Method Details
#to_range ⇒ Object
13 14 15 |
# File 'lib/month_period.rb', line 13 def to_range start..finish end |