Class: Almanack::Event
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Almanack::Event
- Defined in:
- lib/almanack/event.rb
Instance Method Summary collapse
- #description ⇒ Object
-
#end_date ⇒ Object
Deprecated in favour of end_time.
- #end_time ⇒ Object
- #formatted_date ⇒ Object
- #formatted_duration ⇒ Object
- #location ⇒ Object
- #serialized ⇒ Object
-
#start_date ⇒ Object
Deprecated in favour of start_time.
- #start_time ⇒ Object
- #title ⇒ Object
Instance Method Details
#description ⇒ Object
31 32 33 |
# File 'lib/almanack/event.rb', line 31 def description self[:description]&.force_encoding('UTF-8') end |
#end_date ⇒ Object
Deprecated in favour of end_time
45 46 47 |
# File 'lib/almanack/event.rb', line 45 def end_date deprecated :end_date, newer_method: :end_time end |
#end_time ⇒ Object
49 50 51 |
# File 'lib/almanack/event.rb', line 49 def end_time read_attribute :end_time, fallback: :end_date end |
#formatted_date ⇒ Object
5 6 7 8 |
# File 'lib/almanack/event.rb', line 5 def formatted_date warn "formatted_date is deprecated, please use formatted_duration instead" formatted_duration end |
#formatted_duration ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/almanack/event.rb', line 10 def formatted_duration formatted = "#{formatted_day(start_time)}" formatted << " at #{formatted_time(start_time)}" unless start_time.is_a?(Date) if end_time formatted << " to " unless is_date_ending_on_same_day? formatted << "#{formatted_day(end_time)} at " unless ends_on_same_day? formatted << formatted_time(end_time) unless end_time.is_a?(Date) end formatted end |
#location ⇒ Object
27 28 29 |
# File 'lib/almanack/event.rb', line 27 def location self[:location]&.force_encoding('UTF-8') end |
#serialized ⇒ Object
53 54 55 56 57 |
# File 'lib/almanack/event.rb', line 53 def serialized each_pair.with_object({}) do |(attr, _), hash| hash[attr] = serialize_attribute(attr) end end |
#start_date ⇒ Object
Deprecated in favour of start_time
36 37 38 |
# File 'lib/almanack/event.rb', line 36 def start_date deprecated :start_date, newer_method: :start_time end |
#start_time ⇒ Object
40 41 42 |
# File 'lib/almanack/event.rb', line 40 def start_time read_attribute :start_time, fallback: :start_date end |
#title ⇒ Object
23 24 25 |
# File 'lib/almanack/event.rb', line 23 def title self[:title]&.force_encoding('UTF-8') end |