Class: Human

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/prct06/human.rb

Overview

Human Object with very basic data.

Author:

  • roro

Direct Known Subclasses

Anthropometric

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#ageObject

getter and setter



16
17
18
# File 'lib/prct06/human.rb', line 16

def age
  @age
end

#nameObject

getter and setter



16
17
18
# File 'lib/prct06/human.rb', line 16

def name
  @name
end

#sexObject

getter and setter



16
17
18
# File 'lib/prct06/human.rb', line 16

def sex
  @sex
end

#surnameObject

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

Parameters:

  • other (object)
    Person object

Returns:

  • (bool)
    True or False depending whether the comparison is true or not.


23
24
25
# File 'lib/prct06/human.rb', line 23

def <=>(other)
	@name <=> other.name
end

#age_to_schar

Returns a string containing Age of a Human

Returns:

  • (char)
    Age as string.


76
77
78
# File 'lib/prct06/human.rb', line 76

def age_to_s
	"Age: #{@age}\n"
end

#name_to_schar

Returns a string containing Name Human

Returns:

  • (char)
    Name as string.


52
53
54
# File 'lib/prct06/human.rb', line 52

def name_to_s
	"Name: #{@name}\n"
end

#sex_to_schar

Returns a string containing Sex of a Human

Returns:

  • (char)
    Sex as string.


68
69
70
# File 'lib/prct06/human.rb', line 68

def sex_to_s
	"Sex: #{@sex}\n"
end

#surname_to_schar

Returns a string containing Surname of a Human

Returns:

  • (char)
    Surname as string.


60
61
62
# File 'lib/prct06/human.rb', line 60

def surname_to_s
	"Surname: #{@surname}\n"
end

#to_schar

Returns a string containing Name and Surname of a Human

Returns:

  • (char)
    Name and Surname as string.


44
45
46
# File 'lib/prct06/human.rb', line 44

def to_s
	"#{@name} #{@surname}"
end