Class: Infostrada::Nation

Inherits:
Object
  • Object
show all
Defined in:
lib/infostrada/nation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}, prefix, &block) ⇒ Nation

Returns a new instance of Nation.



14
15
16
17
18
19
20
21
22
# File 'lib/infostrada/nation.rb', line 14

def initialize(hash = {}, prefix, &block)
  hash.each do |key, value|
    match = key.info_snake_case.match(/[cn]_#{prefix}_?(natio\w*)$/)
    self.send("#{$1}=", value) if match
  end

  block.call(self) if block_given?
  self
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/infostrada/nation.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/infostrada/nation.rb', line 4

def name
  @name
end

#short_nameObject

Returns the value of attribute short_name.



4
5
6
# File 'lib/infostrada/nation.rb', line 4

def short_name
  @short_name
end

Class Method Details

.from_json(hash = {}, prefix) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/infostrada/nation.rb', line 6

def self.from_json(hash = {}, prefix)
  self.new(prefix) do |nation|
    nation.id         = hash['id']
    nation.name       = hash['name']
    nation.short_name = hash['short_name']
  end
end

Instance Method Details

#natio=(name) ⇒ Object



28
29
30
# File 'lib/infostrada/nation.rb', line 28

def natio=(name)
  self.name = name
end

#natio_geo_id=(id) ⇒ Object



24
25
26
# File 'lib/infostrada/nation.rb', line 24

def natio_geo_id=(id)
  self.id = id
end

#natio_short=(short_name) ⇒ Object



32
33
34
# File 'lib/infostrada/nation.rb', line 32

def natio_short=(short_name)
  self.short_name = short_name
end