Class: Human
Overview
Human Object with very basic data.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#age ⇒ Object
getter and setter.
-
#name ⇒ Object
getter and setter.
-
#sex ⇒ Object
getter and setter.
-
#surname ⇒ Object
getter and setter.
Instance Method Summary collapse
-
#<=>(other) ⇒ bool
[Sets how and what to compare].
-
#age_to_s ⇒ char
Returns a string containing Age of a Human.
-
#initialize(name, surname, sex, age) ⇒ nil
constructor
[nothing].
-
#name_to_s ⇒ char
Returns a string containing Name Human.
-
#sex_to_s ⇒ char
Returns a string containing Sex of a Human.
-
#surname_to_s ⇒ char
Returns a string containing Surname of a Human.
-
#to_s ⇒ char
Returns a string containing Name and Surname of a Human.
Constructor Details
#initialize(name, surname, sex, age) ⇒ nil
Returns [nothing].
35 36 37 |
# File 'lib/prct06/human.rb', line 35 def initialize(name, surname, sex, age) @name, @surname, @sex, @age = name, surname, sex, age end |
Instance Attribute Details
#age ⇒ Object
getter and setter
16 17 18 |
# File 'lib/prct06/human.rb', line 16 def age @age end |
#name ⇒ Object
getter and setter
16 17 18 |
# File 'lib/prct06/human.rb', line 16 def name @name end |
#sex ⇒ Object
getter and setter
16 17 18 |
# File 'lib/prct06/human.rb', line 16 def sex @sex end |
#surname ⇒ Object
getter and setter
16 17 18 |
# File 'lib/prct06/human.rb', line 16 def surname @surname end |
Instance Method Details
#<=>(other) ⇒ bool
- Sets how and what to compare
23 24 25 |
# File 'lib/prct06/human.rb', line 23 def <=>(other) @name <=> other.name end |
#age_to_s ⇒ char
Returns a string containing Age of a Human
76 77 78 |
# File 'lib/prct06/human.rb', line 76 def age_to_s "Age: #{@age}\n" end |
#name_to_s ⇒ char
Returns a string containing Name Human
52 53 54 |
# File 'lib/prct06/human.rb', line 52 def name_to_s "Name: #{@name}\n" end |
#sex_to_s ⇒ char
Returns a string containing Sex of a Human
68 69 70 |
# File 'lib/prct06/human.rb', line 68 def sex_to_s "Sex: #{@sex}\n" end |
#surname_to_s ⇒ char
Returns a string containing Surname of a Human
60 61 62 |
# File 'lib/prct06/human.rb', line 60 def surname_to_s "Surname: #{@surname}\n" end |
#to_s ⇒ char
Returns a string containing Name and Surname of a Human
44 45 46 |
# File 'lib/prct06/human.rb', line 44 def to_s "#{@name} #{@surname}" end |