Class: LibTAD::Holidays::Holiday
- Inherits:
-
Object
- Object
- LibTAD::Holidays::Holiday
- Defined in:
- lib/types/holidays/holiday.rb
Overview
A holiday event.
Instance Attribute Summary collapse
-
#country ⇒ ::LibTAD::Models::Country
readonly
Country of the holiday instance.
-
#date ⇒ ::LibTAD::TADTime::TADTime
readonly
Date/time of the holiday instance.
-
#id ⇒ Integer
readonly
Identifier for the holiday definition.
-
#locations ⇒ String
readonly
Summary of locations where this holiday instance is valid.
-
#name ⇒ Hash<String, String>
readonly
Hash of languages with corresponding holiday/observance name.
-
#oneliner ⇒ Hash<String, String>
readonly
Languages with corresponding holiday description.
-
#states ⇒ Array<HolidayState>
readonly
States/subdivisions that are affected by this holiday instance.
-
#types ⇒ Array<String>
readonly
Classification of the holiday.
-
#uid ⇒ String
readonly
Id for the shown holiday instance.
-
#url ⇒ String
readonly
Further information about the specific holiday.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Holiday
constructor
A new instance of Holiday.
Constructor Details
#initialize(hash) ⇒ Holiday
Returns a new instance of Holiday.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/types/holidays/holiday.rb', line 71 def initialize(hash) @id = hash.fetch('id', nil) @uid = hash.fetch('uid', nil) @name = hash.fetch('name', nil) &.map { |e| [ e['lang'], e['text'] ] } .to_h @date = ::LibTAD::TADTime::TADTime.new hash.fetch('date', nil) @url = hash.fetch('url', nil) @country = ::LibTAD::Places::Country.new hash['country'] unless !hash.key?('country') @locations = hash.fetch('locations', nil) @states = hash.fetch('states', nil) &.map { |e| HolidayState.new(e) } @oneliner = hash.fetch('oneliner', nil) &.map { |e| [ e['lang'], e['text'] ] } .to_h @types = hash.fetch('types', nil) end |
Instance Attribute Details
#country ⇒ ::LibTAD::Models::Country (readonly)
Country of the holiday instance.
46 47 48 |
# File 'lib/types/holidays/holiday.rb', line 46 def country @country end |
#date ⇒ ::LibTAD::TADTime::TADTime (readonly)
Date/time of the holiday instance. Most holidays do have a specific time – in this case the time components will be skipped. Some special events like equinoxes and solstices include the exact time of the event as well, in this case the timestamp will be in local time zone (including time zone data) (countries with multiple timezones: local time in capital city).
35 36 37 |
# File 'lib/types/holidays/holiday.rb', line 35 def date @date end |
#id ⇒ Integer (readonly)
Identifier for the holiday definition. Please note that this id is not unique, not even with a single year – the same holiday event may be returned multiple time because it is observed on a different day, or because it is scheduled in a different calendar (Hebrew or Muslim calendar) and happens multiple times within a Gregorian year. Use the uid attribute for purposes where you need a unique identifier.
13 14 15 |
# File 'lib/types/holidays/holiday.rb', line 13 def id @id end |
#locations ⇒ String (readonly)
Summary of locations where this holiday instance is valid. Element is only present if the holiday instance does not affect the whole country.
51 52 53 |
# File 'lib/types/holidays/holiday.rb', line 51 def locations @locations end |
#name ⇒ Hash<String, String> (readonly)
Hash of languages with corresponding holiday/observance name.
26 27 28 |
# File 'lib/types/holidays/holiday.rb', line 26 def name @name end |
#oneliner ⇒ Hash<String, String> (readonly)
Languages with corresponding holiday description.
61 62 63 |
# File 'lib/types/holidays/holiday.rb', line 61 def oneliner @oneliner end |
#states ⇒ Array<HolidayState> (readonly)
States/subdivisions that are affected by this holiday instance. This element is only present if the holiday instance is not valid in the whole country.
57 58 59 |
# File 'lib/types/holidays/holiday.rb', line 57 def states @states end |
#types ⇒ Array<String> (readonly)
Classification of the holiday. Most days have only one classification, but some have multiple types associated. This happens e.g. in conjunction with religious days that also are flag days.
Example: National Holiday
69 70 71 |
# File 'lib/types/holidays/holiday.rb', line 69 def types @types end |
#uid ⇒ String (readonly)
Id for the shown holiday instance. The id is designed to be unique across all holiday instances generated by the timeanddate.com API services and respects different calendars and other reasons that may cause events to occurs multiple times within one Gregorian year.
Example: 0007d600000007db
22 23 24 |
# File 'lib/types/holidays/holiday.rb', line 22 def uid @uid end |
#url ⇒ String (readonly)
Further information about the specific holiday. The URL points to the timeanddate.com web page.
42 43 44 |
# File 'lib/types/holidays/holiday.rb', line 42 def url @url end |