Class: Kovacs::Person
- Inherits:
-
Object
- Object
- Kovacs::Person
- Defined in:
- lib/kovacs/person.rb
Instance Attribute Summary collapse
-
#forename ⇒ Object
Returns the value of attribute forename.
-
#middle_name ⇒ Object
Returns the value of attribute middle_name.
-
#nationality ⇒ Object
Returns the value of attribute nationality.
-
#sex ⇒ Object
Returns the value of attribute sex.
-
#surname ⇒ Object
Returns the value of attribute surname.
Instance Method Summary collapse
Instance Attribute Details
#forename ⇒ Object
Returns the value of attribute forename.
3 4 5 |
# File 'lib/kovacs/person.rb', line 3 def forename @forename end |
#middle_name ⇒ Object
Returns the value of attribute middle_name.
3 4 5 |
# File 'lib/kovacs/person.rb', line 3 def middle_name @middle_name end |
#nationality ⇒ Object
Returns the value of attribute nationality.
3 4 5 |
# File 'lib/kovacs/person.rb', line 3 def nationality @nationality end |
#sex ⇒ Object
Returns the value of attribute sex.
3 4 5 |
# File 'lib/kovacs/person.rb', line 3 def sex @sex end |
#surname ⇒ Object
Returns the value of attribute surname.
3 4 5 |
# File 'lib/kovacs/person.rb', line 3 def surname @surname end |
Instance Method Details
#name ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/kovacs/person.rb', line 5 def name names = [] << surname << middle_name << forename if nationality.eq?(:hungarian) names.join(' ') else names.reverse.join(' ') end end |
#to_h ⇒ Object
14 15 16 |
# File 'lib/kovacs/person.rb', line 14 def to_h instance_variables.each_with_object({}) { |v, h| h[v.to_s.delete('@').to_sym] = instance_variable_get(v) } end |