You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
489 B
Ruby
36 lines
489 B
Ruby
class PrintyBoy
|
|
def initialize(stream)
|
|
@stream = stream
|
|
end
|
|
|
|
def print_em
|
|
@stream.each {|y| puts y}
|
|
end
|
|
end
|
|
|
|
class CharStream
|
|
include Enumerable
|
|
|
|
def initialize(str)
|
|
puts "str.chars: #{str.chars.class} of #{str.chars.length} chars"
|
|
@str = str.chars
|
|
end
|
|
|
|
def each(&block)
|
|
@str.each &block
|
|
end
|
|
|
|
def empty?
|
|
@str.empty?
|
|
end
|
|
|
|
def length
|
|
@str.length
|
|
end
|
|
end
|
|
|
|
cs = CharStream.new "cockshitbitchcuntaahhhh"
|
|
pb = PrintyBoy.new cs
|
|
|
|
pb.print_em
|