Class: Human

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

Instance Method Summary collapse

Constructor Details

#initialize(height, weight) ⇒ Human

Returns a new instance of Human.



2
3
4
5
# File 'lib/bmi.rb', line 2

def initialize(height,weight)
  @height = height
  @weight = weight
end

Instance Method Details

#bmiObject



11
12
13
# File 'lib/bmi.rb', line 11

def bmi
  (@weight / (@height/100 * @height/100)).round(1)
end

#helloObject



7
8
9
# File 'lib/bmi.rb', line 7

def hello
  puts "こんにちは。身長は #{@height}で、体重は #{@weight}です。"
end

#hello2Object



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

def hello2
  puts "BMI値は#{bmi}です。よろしくお願いします。"
end