Class: Cardigan::Io

Inherits:
Object
  • Object
show all
Defined in:
lib/cardigan/io.rb

Instance Method Summary collapse

Constructor Details

#initialize(in_io = $stdin, out_io = $stdout) ⇒ Io

Returns a new instance of Io.



3
4
5
# File 'lib/cardigan/io.rb', line 3

def initialize in_io=$stdin, out_io=$stdout
  @in_io, @out_io = in_io, out_io
end

Instance Method Details

#ask(prompt) ⇒ Object



7
8
9
10
# File 'lib/cardigan/io.rb', line 7

def ask prompt
  @out_io.print "#{prompt} > "
  @in_io.gets.chomp
end

#say(message = '') ⇒ Object



12
13
14
# File 'lib/cardigan/io.rb', line 12

def say message=''
  @out_io.puts message
end