Skip to content

Instantly share code, notes, and snippets.

@X1ting
Created April 17, 2018 07:49
Show Gist options
  • Select an option

  • Save X1ting/fa99fa0e73dd8bad0841df872873ba8f to your computer and use it in GitHub Desktop.

Select an option

Save X1ting/fa99fa0e73dd8bad0841df872873ba8f to your computer and use it in GitHub Desktop.
module Cash
def pay(amount)
self.cash = self.cash + amount
end
end
class Kino
include Cash
attr_accessor :cash
def buy
pay(10)
end
end
class Netflix
extend Cash
class << self
attr_accessor :cash
def buy
pay(10)
end
end
end
puts 'KINO'
kino = Kino.new
kino.cash = 20
puts kino.cash
kino.buy
puts kino.cash
puts 'KINO END'
puts 'NETFLIX'
Netflix.cash = 20
puts Netflix.cash
Netflix.buy
puts Netflix.cash
puts 'NETFLIX END'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment