Class: Anthropometric

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

Overview

Anthropometric Object is a Child class from the Human with extented data sobre la salud.

Author:

  • roro

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Human

#<=>, #age_to_s, #name_to_s, #sex_to_s, #surname_to_s, #to_s

Constructor Details

#initialize(name, surname, sex, age, height, weight, waist, hip, triceps, bicipital, subscapular, suprailiac, arm) ⇒ nil

Returns [nothing].



108
109
110
111
# File 'lib/prct06/human.rb', line 108

def initialize(name, surname, sex, age, height, weight, waist, hip, triceps, bicipital, subscapular, suprailiac, arm)
	super(name, surname, sex, age)
	@height, @weight, @waist, @hip, @triceps, @bicipital, @subscapular, @suprailiac, @arm = height, weight, waist, hip, triceps, bicipital, subscapular, suprailiac, arm
end

Instance Attribute Details

#ageObject

getter and setter all in one



89
90
91
# File 'lib/prct06/human.rb', line 89

def age
  @age
end

#heightObject

getter and setter all in one



89
90
91
# File 'lib/prct06/human.rb', line 89

def height
  @height
end

#nameObject

getter and setter all in one



89
90
91
# File 'lib/prct06/human.rb', line 89

def name
  @name
end

#sexObject

getter and setter all in one



89
90
91
# File 'lib/prct06/human.rb', line 89

def sex
  @sex
end

#surnameObject

getter and setter all in one



89
90
91
# File 'lib/prct06/human.rb', line 89

def surname
  @surname
end

#weightObject

getter and setter all in one



89
90
91
# File 'lib/prct06/human.rb', line 89

def weight
  @weight
end

Instance Method Details

#arm_to_schar

Returns a string containing Triceps of an Anthropometric

Returns:

  • (char)
    Triceps as string.


181
182
183
# File 'lib/prct06/human.rb', line 181

def arm_to_s
	return uni_med(@arm)
end

#biceps_to_schar

Returns a string containing Biceps of an Anthropometric

Returns:

  • (char)
    Biceps as string.


157
158
159
# File 'lib/prct06/human.rb', line 157

def biceps_to_s
	return uni_med(@bicipital)
end

#height_to_schar

Returns a string containing Height of an Anthropometric

Returns:

  • (char)
    Height as string.


117
118
119
# File 'lib/prct06/human.rb', line 117

def height_to_s
	"Height: #{@height}\n"
end

#hip_to_schar

Returns a string containing Hip of an Anthropometric

Returns:

  • (char)
    Hip as string.


141
142
143
# File 'lib/prct06/human.rb', line 141

def hip_to_s
	return uni_med(@hip)
end

#imcchar

Returns the calculated IMC of an Anthropometric

Returns:

  • (char)
    IMC of Anthropometric


203
204
205
# File 'lib/prct06/human.rb', line 203

def imc
	return (@weight/@height**2).round(2)
end

#porc_fatchar

Returns the calculated percentage of fat of an Anthropometric

Returns:

  • (char)
    Percentage of fat of an Anthropometric


219
220
221
# File 'lib/prct06/human.rb', line 219

def porc_fat
	return (1.2 * imc + 0.23 * @age - 10.8 * @sex -5.4).round(2)
end

#rccchar

Returns the calculated RCC of an Anthropometric

Returns:

  • (char)
    RCC of Anthropometric


211
212
213
# File 'lib/prct06/human.rb', line 211

def rcc
	return (waist_to_s()/hip_to_s).round(2)
end

#subscapular_to_schar

Returns a string containing Subcapular of an Anthropometric

Returns:

  • (char)
    Subcapular as string.


165
166
167
# File 'lib/prct06/human.rb', line 165

def subscapular_to_s
	return uni_med(@subscapular)
end

#suprailiac_to_schar

Returns a string containing Suprailiac of an Anthropometric

Returns:

  • (char)
    Suprailiac as string.


173
174
175
# File 'lib/prct06/human.rb', line 173

def suprailiac_to_s
	return uni_med(@suprailiac)
end

#triceps_to_schar

Returns a string containing Triceps of an Anthropometric

Returns:

  • (char)
    Triceps as string.


149
150
151
# File 'lib/prct06/human.rb', line 149

def triceps_to_s
	return uni_med(@triceps)
end

#uni_med(li) ⇒ float

Universal Median Calculator

Parameters:

  • li (list)
    List of Numbers of which the median should be calculated

Returns:

  • (float)
    Returns Median


190
191
192
193
194
195
196
197
# File 'lib/prct06/human.rb', line 190

def uni_med(li)
	sum, i = 0, 0
	while(i < li.length)
		sum += li[i]
		i += 1
	end
	return (sum/li.length).round(2)
end

#waist_to_schar

Returns a string containing Waist of an Anthropometric

Returns:

  • (char)
    Waist as string.


133
134
135
# File 'lib/prct06/human.rb', line 133

def waist_to_s
	return uni_med(@waist)
end

#weight_to_schar

Returns a string containing Weight of an Anthropometric

Returns:

  • (char)
    Weight as string.


125
126
127
# File 'lib/prct06/human.rb', line 125

def weight_to_s
	"Weight: #{@weight}\n"
end