Class: MonthPeriod

Inherits:
Object
  • Object
show all
Defined in:
lib/month_period.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#finishObject (readonly)

Returns the value of attribute finish.



4
5
6
# File 'lib/month_period.rb', line 4

def finish
  @finish
end

#monthObject (readonly)

Returns the value of attribute month.



4
5
6
# File 'lib/month_period.rb', line 4

def month
  @month
end

#startObject (readonly)

Returns the value of attribute start.



4
5
6
# File 'lib/month_period.rb', line 4

def start
  @start
end

#yearObject (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_rangeObject



13
14
15
# File 'lib/month_period.rb', line 13

def to_range
  start..finish
end