Class: Fonecal::Event
- Inherits:
-
Object
- Object
- Fonecal::Event
- Defined in:
- lib/fonecal/event.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#end ⇒ Object
Returns the value of attribute end.
-
#name ⇒ Object
Returns the value of attribute name.
-
#start ⇒ Object
Returns the value of attribute start.
Instance Method Summary collapse
-
#initialize(event, timezone) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(event, timezone) ⇒ Event
Returns a new instance of Event.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fonecal/event.rb', line 7 def initialize(event, timezone) self.name = event[:type] # Extract info from date string date,month,year = event[:date].split(' ')[1..-1] # Convert month from string to integer month = Date::MONTHNAMES.index(month) # Parse and set starting time start_hr, start_m = event[:start].split(':') # Set timezone to what was given Time.zone = timezone.zone # Look up timezone in day, taking dst into account @start = Time.zone.local(year, month, date, start_hr, start_m, 0) # Parse and set ending time if event[:end] # a practice sessions end_hr, end_m = event[:end].split(':') @end = Time.zone.local(year, month, date, end_hr, end_m, 0) elsif self.class == Qualifying @end = @start + (1.hour + 30.minutes) else # race @end = @start + 4.hours end end |
Instance Attribute Details
#end ⇒ Object
Returns the value of attribute end.
5 6 7 |
# File 'lib/fonecal/event.rb', line 5 def end @end end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/fonecal/event.rb', line 5 def name @name end |
#start ⇒ Object
Returns the value of attribute start.
5 6 7 |
# File 'lib/fonecal/event.rb', line 5 def start @start end |