Class: Biz::Holiday
- Inherits:
-
Object
- Object
- Biz::Holiday
- Defined in:
- lib/biz/holiday.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
(also: #to_date)
readonly
Returns the value of attribute date.
-
#time_zone ⇒ Object
readonly
Returns the value of attribute time_zone.
Instance Method Summary collapse
- #contains?(time) ⇒ Boolean
-
#initialize(date, time_zone) ⇒ Holiday
constructor
A new instance of Holiday.
- #to_time_segment ⇒ Object
Constructor Details
#initialize(date, time_zone) ⇒ Holiday
Returns a new instance of Holiday.
9 10 11 12 |
# File 'lib/biz/holiday.rb', line 9 def initialize(date, time_zone) @date = date @time_zone = time_zone end |
Instance Attribute Details
#date ⇒ Object (readonly) Also known as: to_date
Returns the value of attribute date.
6 7 8 |
# File 'lib/biz/holiday.rb', line 6 def date @date end |
#time_zone ⇒ Object (readonly)
Returns the value of attribute time_zone.
6 7 8 |
# File 'lib/biz/holiday.rb', line 6 def time_zone @time_zone end |
Instance Method Details
#contains?(time) ⇒ Boolean
14 15 16 |
# File 'lib/biz/holiday.rb', line 14 def contains?(time) date == Time.new(time_zone).local(time).to_date end |
#to_time_segment ⇒ Object
18 19 20 21 22 23 |
# File 'lib/biz/holiday.rb', line 18 def to_time_segment TimeSegment.new( Time.new(time_zone).on_date(date, DayTime.midnight), Time.new(time_zone).on_date(date, DayTime.endnight) ) end |