Class: XMP::StringInputMethod

Inherits:
IRB::InputMethod show all
Defined in:
lib/irb/xmp.rb

Instance Attribute Summary

Attributes inherited from IRB::InputMethod

#file_name, #prompt

Instance Method Summary collapse

Methods inherited from IRB::InputMethod

#readable_atfer_eof?

Constructor Details

#initializeStringInputMethod

Returns a new instance of StringInputMethod.



56
57
58
59
# File 'lib/irb/xmp.rb', line 56

def initialize
  super
  @exps = []
end

Instance Method Details

#eof?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/irb/xmp.rb', line 61

def eof?
  @exps.empty?
end

#getsObject



65
66
67
68
69
70
71
72
73
# File 'lib/irb/xmp.rb', line 65

def gets
  while l = @exps.shift
	next if /^\s+$/ =~ l
	l.concat "\n"
	print @prompt, l
	break
  end
  l
end

#puts(exps) ⇒ Object



75
76
77
# File 'lib/irb/xmp.rb', line 75

def puts(exps)
  @exps.concat exps.split(/\n/)
end