Class: Kovacs::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/kovacs/person.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#forenameObject

Returns the value of attribute forename.



3
4
5
# File 'lib/kovacs/person.rb', line 3

def forename
  @forename
end

#middle_nameObject

Returns the value of attribute middle_name.



3
4
5
# File 'lib/kovacs/person.rb', line 3

def middle_name
  @middle_name
end

#nationalityObject

Returns the value of attribute nationality.



3
4
5
# File 'lib/kovacs/person.rb', line 3

def nationality
  @nationality
end

#sexObject

Returns the value of attribute sex.



3
4
5
# File 'lib/kovacs/person.rb', line 3

def sex
  @sex
end

#surnameObject

Returns the value of attribute surname.



3
4
5
# File 'lib/kovacs/person.rb', line 3

def surname
  @surname
end

Instance Method Details

#nameObject



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_hObject



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