Class: HolidaysRest::Holiday

Inherits:
Data
  • Object
show all
Defined in:
lib/holidays_rest/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#country_codeObject (readonly)

Returns the value of attribute country_code

Returns:

  • (Object)

    the current value of country_code



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def country_code
  @country_code
end

#country_nameObject (readonly)

Returns the value of attribute country_name

Returns:

  • (Object)

    the current value of country_name



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def country_name
  @country_name
end

#dateObject (readonly)

Returns the value of attribute date

Returns:

  • (Object)

    the current value of date



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def date
  @date
end

#dayObject (readonly)

Returns the value of attribute day

Returns:

  • (Object)

    the current value of day



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def day
  @day
end

#is_estimateObject (readonly)

Returns the value of attribute is_estimate

Returns:

  • (Object)

    the current value of is_estimate



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def is_estimate
  @is_estimate
end

#is_localObject (readonly)

Returns the value of attribute is_local

Returns:

  • (Object)

    the current value of is_local



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def is_local
  @is_local
end

#is_nationalObject (readonly)

Returns the value of attribute is_national

Returns:

  • (Object)

    the current value of is_national



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def is_national
  @is_national
end

#is_religiousObject (readonly)

Returns the value of attribute is_religious

Returns:

  • (Object)

    the current value of is_religious



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def is_religious
  @is_religious
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def name
  @name
end

#regionsObject (readonly)

Returns the value of attribute regions

Returns:

  • (Object)

    the current value of regions



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def regions
  @regions
end

#religionObject (readonly)

Returns the value of attribute religion

Returns:

  • (Object)

    the current value of religion



11
12
13
# File 'lib/holidays_rest/models.rb', line 11

def religion
  @religion
end

Class Method Details

.from_hash(h) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/holidays_rest/models.rb', line 14

def self.from_hash(h)
  new(
    country_code: h.fetch("country_code", ""),
    country_name: h.fetch("country_name", ""),
    date:         h.fetch("date", ""),
    name:         h.fetch("name", {}),
    is_national:  h.fetch("isNational", false),
    is_religious: h.fetch("isReligious", false),
    is_local:     h.fetch("isLocal", false),
    is_estimate:  h.fetch("isEstimate", false),
    day:          HolidayDay.from_hash(h.fetch("day", {})),
    religion:     h.fetch("religion", ""),
    regions:      Array(h["regions"])
  )
end