Class: HolidaysRest::Country

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#alpha2Object (readonly)

Returns the value of attribute alpha2

Returns:

  • (Object)

    the current value of alpha2



37
38
39
# File 'lib/holidays_rest/models.rb', line 37

def alpha2
  @alpha2
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



37
38
39
# File 'lib/holidays_rest/models.rb', line 37

def name
  @name
end

#subdivisionsObject (readonly)

Returns the value of attribute subdivisions

Returns:

  • (Object)

    the current value of subdivisions



37
38
39
# File 'lib/holidays_rest/models.rb', line 37

def subdivisions
  @subdivisions
end

Class Method Details

.from_hash(h) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/holidays_rest/models.rb', line 38

def self.from_hash(h)
  new(
    name:         h.fetch("name", ""),
    alpha2:       h.fetch("alpha2", ""),
    subdivisions: Array(h["subdivisions"]).map { Subdivision.from_hash(_1) }
  )
end