Class: KanjiMaster::Address
- Inherits:
-
Object
- Object
- KanjiMaster::Address
- Defined in:
- lib/kanji_master/address.rb
Overview
Address get data from Person.rb which access the data from ‘person.yml`
Instance Attribute Summary collapse
-
#hira ⇒ Object
Returns the value of attribute hira.
-
#hiragana ⇒ Object
Returns the value of attribute hiragana.
-
#kana ⇒ Object
Returns the value of attribute kana.
-
#katakana ⇒ Object
Returns the value of attribute katakana.
-
#name ⇒ Object
Returns the value of attribute name.
-
#zip_code ⇒ Object
Returns the value of attribute zip_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(address) ⇒ Address
constructor
A new instance of Address.
Constructor Details
#initialize(address) ⇒ Address
Returns a new instance of Address.
21 22 23 24 25 26 27 28 29 |
# File 'lib/kanji_master/address.rb', line 21 def initialize(address) converter = Converter.new @zip_code = address['zip_code'] @name = address['name'] @katakana = address['katakana'] @kana = @katakana @hiragana = converter.hira(@katakana) @hira = @hiragana end |
Instance Attribute Details
#hira ⇒ Object
Returns the value of attribute hira.
8 9 10 |
# File 'lib/kanji_master/address.rb', line 8 def hira @hira end |
#hiragana ⇒ Object
Returns the value of attribute hiragana.
8 9 10 |
# File 'lib/kanji_master/address.rb', line 8 def hiragana @hiragana end |
#kana ⇒ Object
Returns the value of attribute kana.
8 9 10 |
# File 'lib/kanji_master/address.rb', line 8 def kana @kana end |
#katakana ⇒ Object
Returns the value of attribute katakana.
8 9 10 |
# File 'lib/kanji_master/address.rb', line 8 def katakana @katakana end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/kanji_master/address.rb', line 8 def name @name end |
#zip_code ⇒ Object
Returns the value of attribute zip_code.
8 9 10 |
# File 'lib/kanji_master/address.rb', line 8 def zip_code @zip_code end |
Class Method Details
.data ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/kanji_master/address.rb', line 13 def self.data @data['persons']['person'].map do |h| new_hash = h.slice('address', 'address_kata', 'zip') if h['address'].present? && h['zip'].present? keys = { "address" => "name", "address_kata" => "katakana", "zip" => "zip_code" } Hash[new_hash.map{ |k, v| [keys[k], v]}] end end |