Class: KanjiMaster::Name
- Inherits:
-
Object
- Object
- KanjiMaster::Name
- Defined in:
- lib/kanji_master/name.rb
Overview
Name get data from Person.rb which access the data from ‘person.yml`
Instance Attribute Summary collapse
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#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.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#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(name) ⇒ Name
constructor
A new instance of Name.
Constructor Details
#initialize(name) ⇒ Name
Returns a new instance of Name.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kanji_master/name.rb', line 21 def initialize(name) converter = Converter.new @full_name = name['full_name'] @first_name = @full_name.split[1] @last_name = @full_name.split[0] @katakana = name['katakana'] @kana = @katakana @hiragana = converter.hira(@katakana) @hira = @hiragana end |
Instance Attribute Details
#first_name ⇒ Object
Returns the value of attribute first_name.
8 9 10 |
# File 'lib/kanji_master/name.rb', line 8 def first_name @first_name end |
#hira ⇒ Object
Returns the value of attribute hira.
8 9 10 |
# File 'lib/kanji_master/name.rb', line 8 def hira @hira end |
#hiragana ⇒ Object
Returns the value of attribute hiragana.
8 9 10 |
# File 'lib/kanji_master/name.rb', line 8 def hiragana @hiragana end |
#kana ⇒ Object
Returns the value of attribute kana.
8 9 10 |
# File 'lib/kanji_master/name.rb', line 8 def kana @kana end |
#katakana ⇒ Object
Returns the value of attribute katakana.
8 9 10 |
# File 'lib/kanji_master/name.rb', line 8 def katakana @katakana end |
#last_name ⇒ Object
Returns the value of attribute last_name.
8 9 10 |
# File 'lib/kanji_master/name.rb', line 8 def last_name @last_name end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/kanji_master/name.rb', line 8 def name @name end |
#zip_code ⇒ Object
Returns the value of attribute zip_code.
8 9 10 |
# File 'lib/kanji_master/name.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/name.rb', line 13 def self.data @data['persons']['person'].map do |h| new_hash = h.slice('name', 'name_kana') if h['name'].present? && h['name_kana'].present? keys = { "name" => "full_name", "name_kana" => "katakana" } Hash[new_hash.map{ |k, v| [keys[k], v]}] end end |