Class: JpCityCode::CityCode

Inherits:
Object
  • Object
show all
Defined in:
lib/jp_city_code/city_code.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#city_codeObject

Returns the value of attribute city_code.



4
5
6
# File 'lib/jp_city_code/city_code.rb', line 4

def city_code
  @city_code
end

#city_nameObject

Returns the value of attribute city_name.



4
5
6
# File 'lib/jp_city_code/city_code.rb', line 4

def city_name
  @city_name
end

#city_name_kObject

Returns the value of attribute city_name_k.



4
5
6
# File 'lib/jp_city_code/city_code.rb', line 4

def city_name_k
  @city_name_k
end

#prefecture_nameObject

Returns the value of attribute prefecture_name.



4
5
6
# File 'lib/jp_city_code/city_code.rb', line 4

def prefecture_name
  @prefecture_name
end

#prefecture_name_kObject

Returns the value of attribute prefecture_name_k.



4
5
6
# File 'lib/jp_city_code/city_code.rb', line 4

def prefecture_name_k
  @prefecture_name_k
end

Class Method Details

.build(city_code, prefecture_name, city_name, prefecture_name_k, city_name_k) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/jp_city_code/city_code.rb', line 6

def self.build(city_code, prefecture_name, city_name, prefecture_name_k, city_name_k)
  city = self.new
  city.city_code         = city_code
  city.prefecture_name   = prefecture_name
  city.city_name         = city_name
  city.prefecture_name_k = prefecture_name_k
  city.city_name_k       = city_name_k

  city
end

.find(city_code) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/jp_city_code/city_code.rb', line 17

def self.find(city_code)
  return if city_code.nil?
  return unless city_code.is_a?(String)
  ret = Mapping.data[city_code]
  return unless ret

  self.build(ret[:city_code], ret[:prefecture_name], ret[:city_name], ret[:prefecture_name_k], ret[:city_name_k])
end