Class: Human
- Inherits:
-
Object
- Object
- Human
- Defined in:
- lib/bmi.rb
Instance Method Summary collapse
- #bmi ⇒ Object
- #hello ⇒ Object
- #hello2 ⇒ Object
-
#initialize(height, weight) ⇒ Human
constructor
A new instance of Human.
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
#bmi ⇒ Object
11 12 13 |
# File 'lib/bmi.rb', line 11 def bmi (@weight / (@height/100 * @height/100)).round(1) end |
#hello ⇒ Object
7 8 9 |
# File 'lib/bmi.rb', line 7 def hello puts "こんにちは。身長は #{@height}で、体重は #{@weight}です。" end |
#hello2 ⇒ Object
16 17 18 |
# File 'lib/bmi.rb', line 16 def hello2 puts "BMI値は#{bmi}です。よろしくお願いします。" end |