Class: LibTAD::OnThisDay::Event
- Inherits:
-
Object
- Object
- LibTAD::OnThisDay::Event
- Defined in:
- lib/types/onthisday/event.rb
Overview
A historical event.
Instance Attribute Summary collapse
-
#categories ⇒ Array<String>
readonly
Event categories.
-
#countries ⇒ Array<::LibTAD::Places::Country>
readonly
Related countries.
-
#date ⇒ ::LibTAD::TADTime::TADTime
readonly
Date of the event.
-
#description ⇒ Hash<String, String>
readonly
Languages with corresponding event description.
-
#id ⇒ Integer
readonly
Identifier for the event.
-
#location ⇒ String
readonly
Location of the event.
-
#name ⇒ Hash<String, String>
readonly
Hash of languages with corresponding event name.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(hash) ⇒ Event
Returns a new instance of Event.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/types/onthisday/event.rb', line 33 def initialize(hash) @id = hash.fetch('id', nil) @name = hash.fetch('name', nil) &.map { |e| [ e['lang'], e['text'] ] } .to_h @date = ::LibTAD::TADTime::TADTime.new hash.fetch('date', nil) @location = hash.fetch('location', nil) @categories = hash.fetch('categories', nil) @countries = hash.fetch('countries', nil) &.map { |e| ::LibTAD::Places::Country.new(e) } @description = hash.fetch('description', nil) &.map { |e| [ e['lang'], e['text'] ] } .to_h end |
Instance Attribute Details
#categories ⇒ Array<String> (readonly)
Event categories.
23 24 25 |
# File 'lib/types/onthisday/event.rb', line 23 def categories @categories end |
#countries ⇒ Array<::LibTAD::Places::Country> (readonly)
Related countries.
27 28 29 |
# File 'lib/types/onthisday/event.rb', line 27 def countries @countries end |
#date ⇒ ::LibTAD::TADTime::TADTime (readonly)
Date of the event.
15 16 17 |
# File 'lib/types/onthisday/event.rb', line 15 def date @date end |
#description ⇒ Hash<String, String> (readonly)
Languages with corresponding event description.
31 32 33 |
# File 'lib/types/onthisday/event.rb', line 31 def description @description end |
#id ⇒ Integer (readonly)
Identifier for the event.
7 8 9 |
# File 'lib/types/onthisday/event.rb', line 7 def id @id end |
#location ⇒ String (readonly)
Location of the event.
19 20 21 |
# File 'lib/types/onthisday/event.rb', line 19 def location @location end |
#name ⇒ Hash<String, String> (readonly)
Hash of languages with corresponding event name.
11 12 13 |
# File 'lib/types/onthisday/event.rb', line 11 def name @name end |