Skip to content

Instantly share code, notes, and snippets.

@jmoon90
Created November 26, 2013 18:52
Show Gist options
  • Select an option

  • Save jmoon90/7663735 to your computer and use it in GitHub Desktop.

Select an option

Save jmoon90/7663735 to your computer and use it in GitHub Desktop.
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
def dry_marker_eraser
@contents = []
end
end
class DryEraseMarker
attr_reader :color, :capacity
def initialize(color)
@color = color
@capacity = 100
end
def ink_remaining?
!@capacity.nil?
end
INK_USE_PER_CHARACTER = 0.01
def write(contents, whiteboard)
@capacity = @capacity - (INK_USE_PER_CHARACTER * contents.length)
whiteboard.contents << contents
end
end
whiteb = Whiteboard.new
black_marker = DryEraseMarker.new("black")
black_marker.write("hello launch", whiteb)
require "pry"
binding.pry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment