Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from YanKozlovskiy/gist:bec874afcae6e5a5d588
Created November 3, 2014 03:43
Show Gist options
  • Save radar/c57a824950599e95c435 to your computer and use it in GitHub Desktop.
Save radar/c57a824950599e95c435 to your computer and use it in GitHub Desktop.
class Player
def initialize(name, health = 100, rank = 1)
@name = name.capitalize
@health = health
@rank = rank
end
def say_hello
puts "#{@name} has #{@health} health and #{@rank} rank."
self
end
def rank_up
@rank += 1
puts "Ranked up! #{@name} now has a rank of #{@rank}!"
self
end
end
player1 = Player.new("joe")
player2 = Player.new("mike")
puts player2.say_hello.rank_up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment