Skip to content

Instantly share code, notes, and snippets.

@foglabs
Created August 29, 2014 15:52
Show Gist options
  • Save foglabs/91c775ca43a2c17306ff to your computer and use it in GitHub Desktop.
Save foglabs/91c775ca43a2c17306ff to your computer and use it in GitHub Desktop.
OOP Fake Class Examp
class Television
def initialize(size, channel)
@channel = channel
@size = size
end
def change_chan(@channel)
puts "Channel changed to #{@channel}."
end
def chan_up
@channel += 1
puts "Channel changed to #{@channel}."
end
def chan_down
@channel -= 1
puts "Channel changed to #{@channel}."
end
end
class TVChan
def initialize(chan_num,chan_name,broadcast_status)
@chan_name = chan_name
@chan_num = chan_num
@broadcast_status = broadcast_status
end
def sign_on
@broadcast_status = true
end
def sign_off
@broadcast_status = false
end
class TVShow
def initialize(length,name)
@length = length
@name = name
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment