Class: LibTAD::OnThisDay::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/types/onthisday/event.rb

Overview

A historical event.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#categoriesArray<String> (readonly)

Event categories.

Returns:

  • (Array<String>)


23
24
25
# File 'lib/types/onthisday/event.rb', line 23

def categories
  @categories
end

#countriesArray<::LibTAD::Places::Country> (readonly)

Related countries.

Returns:



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

#descriptionHash<String, String> (readonly)

Languages with corresponding event description.

Returns:

  • (Hash<String, String>)


31
32
33
# File 'lib/types/onthisday/event.rb', line 31

def description
  @description
end

#idInteger (readonly)

Identifier for the event.

Returns:

  • (Integer)


7
8
9
# File 'lib/types/onthisday/event.rb', line 7

def id
  @id
end

#locationString (readonly)

Location of the event.

Returns:

  • (String)


19
20
21
# File 'lib/types/onthisday/event.rb', line 19

def location
  @location
end

#nameHash<String, String> (readonly)

Hash of languages with corresponding event name.

Returns:

  • (Hash<String, String>)


11
12
13
# File 'lib/types/onthisday/event.rb', line 11

def name
  @name
end