Skip to content

Instantly share code, notes, and snippets.

@sadovnik
Created March 20, 2019 12:59
Show Gist options
  • Save sadovnik/9d3dca043c1242035b4548481a7de5d1 to your computer and use it in GitHub Desktop.
Save sadovnik/9d3dca043c1242035b4548481a7de5d1 to your computer and use it in GitHub Desktop.
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
@sadovnik
Copy link
Author

sadovnik commented Mar 20, 2019

Sample output:

~The cigarette was smoldering slowly. The day came to an end, slowly pouring gold into the tired city sun...
§ health: 99 § status: awesome

~The cigarette was smoldering slowly. The day came to an end, slowly pouring gold into the tired city sun...
§ health: 98 § status: awesome


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment