Created
March 20, 2019 12:59
-
-
Save sadovnik/9d3dca043c1242035b4548481a7de5d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Human | |
attr_reader :health | |
def initialize | |
@health = 100 | |
end | |
def smoke_cigarette | |
@health -= 1 | |
end | |
def status | |
case @health | |
when 95..100 | |
:awesome | |
when 85...95 | |
:very_good | |
when 60...88 | |
:good | |
when 40...60 | |
:fine | |
when 30...40 | |
:shitty | |
when 15...30 | |
:very_poor | |
when 3...15 | |
:critical | |
when 1...3 | |
:dying | |
when 0 | |
:dead | |
end | |
end | |
def inspect | |
"§ health: #{health} § status: #{status}" | |
end | |
end | |
me = Human.new | |
until me.status == :dying | |
me.smoke_cigarette | |
puts "~The cigarette was smoldering slowly. The day came to an end, slowly pouring gold into the tired city sun..." | |
puts me.inspect | |
puts | |
sleep 5 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output: