class IOStub

Public Class Methods

new() click to toggle source
# File lib/mspec/helpers/io.rb, line 4
def initialize
  @buffer = []
  @output = ''
end

Public Instance Methods

<<(str) click to toggle source
# File lib/mspec/helpers/io.rb, line 13
def << str
  @buffer << str
  self
end
==(other) click to toggle source
# File lib/mspec/helpers/io.rb, line 26
def == other
  to_s == other
end
=~(other) click to toggle source
# File lib/mspec/helpers/io.rb, line 30
def =~ other
  to_s =~ other
end
flush() click to toggle source
# File lib/mspec/helpers/io.rb, line 46
def flush
  @output += @buffer.join('')
  @buffer.clear
  self
end
method_missing(name, *args, &block) click to toggle source
# File lib/mspec/helpers/io.rb, line 22
def method_missing(name, *args, &block)
  to_s.send(name, *args, &block)
end
print(*str) click to toggle source
printf(format, *args) click to toggle source
# File lib/mspec/helpers/io.rb, line 42
def printf(format, *args)
  self << sprintf(format, *args)
end
puts(*str) click to toggle source
# File lib/mspec/helpers/io.rb, line 34
def puts(*str)
  if str.empty?
    write "\n"
  else
    write(str.collect { |s| s.to_s.chomp }.concat([nil]).join("\n"))
  end
end
to_s() click to toggle source
# File lib/mspec/helpers/io.rb, line 52
def to_s
  flush
  @output
end
Also aliased as: to_str
to_str() click to toggle source
Alias for: to_s
write(*str) click to toggle source
# File lib/mspec/helpers/io.rb, line 9
def write(*str)
  self << str.join
end