Class: XMP::StringInputMethod
- Inherits:
-
IRB::InputMethod
- Object
- IRB::InputMethod
- XMP::StringInputMethod
- Defined in:
- lib/irb/xmp.rb
Instance Attribute Summary collapse
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
Attributes inherited from IRB::InputMethod
Instance Method Summary collapse
- #eof? ⇒ Boolean
- #gets ⇒ Object
-
#initialize ⇒ StringInputMethod
constructor
A new instance of StringInputMethod.
- #puts(exps) ⇒ Object
Methods inherited from IRB::InputMethod
Constructor Details
#initialize ⇒ StringInputMethod
Returns a new instance of StringInputMethod.
55 56 57 58 |
# File 'lib/irb/xmp.rb', line 55 def initialize super @exps = [] end |
Instance Attribute Details
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding
88 89 90 |
# File 'lib/irb/xmp.rb', line 88 def encoding @encoding end |
Instance Method Details
#eof? ⇒ Boolean
60 61 62 |
# File 'lib/irb/xmp.rb', line 60 def eof? @exps.empty? end |
#gets ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/irb/xmp.rb', line 64 def gets while l = @exps.shift next if /^\s+$/ =~ l l.concat "\n" print @prompt, l break end l end |
#puts(exps) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/irb/xmp.rb', line 74 def puts(exps) if @encoding and exps.encoding != @encoding enc = Encoding.compatible?(@exps.join("\n"), exps) if enc.nil? raise Encoding::CompatibilityError, "Encoding in which the passed expression is encoded is not compatible to the preceding's one" else @encoding = enc end else @encoding = exps.encoding end @exps.concat exps.split(/\n/) end |