D
Daniel Schierbeck
Why haven't I thought of this before?
class Terminal
include Enumerable
def each(&block)
while input = gets
block.call(input.chomp)
end
end
end
terminal = Terminal.new
# terminate the loop with ctrl-d, or whatever works for you.
terminal.entries
terminal.map{|line| line.to_sym}
terminal.inject(""){|str, line| str << line}
Yet another epiphany. Thank you, Ruby.
Cheers,
Daniel
class Terminal
include Enumerable
def each(&block)
while input = gets
block.call(input.chomp)
end
end
end
terminal = Terminal.new
# terminate the loop with ctrl-d, or whatever works for you.
terminal.entries
terminal.map{|line| line.to_sym}
terminal.inject(""){|str, line| str << line}
Yet another epiphany. Thank you, Ruby.
Cheers,
Daniel