Class: Lisp::Format::Output
Overview
Represents output for a State object.
Instance Attribute Summary collapse
-
#col ⇒ Object
The current output column.
Instance Method Summary collapse
-
#<<(str) ⇒ Object
Add
strto the output. -
#initialize(str = '', col = 0) ⇒ Output
constructor
Create a new Output object.
-
#to_s ⇒ Object
Convert this object to its string representation, which is the output gathered so far.
Constructor Details
#initialize(str = '', col = 0) ⇒ Output
Create a new Output object.
111 112 113 |
# File 'lib/carat/lisp-format.rb', line 111 def initialize(str = '', col = 0) @output, @col = str, col end |
Instance Attribute Details
#col ⇒ Object
The current output column.
137 138 139 |
# File 'lib/carat/lisp-format.rb', line 137 def col @col end |
Instance Method Details
#<<(str) ⇒ Object
Add str to the output.
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/carat/lisp-format.rb', line 116 def <<(str) if str.is_a? Fixnum @output << str.chr # How should tabs be handled here? They should perhaps be # interpreted as eight (8) characters wide? This of course depends # on where @col is already at (8 - @col % 8). @col = str == ?\n ? 0 : @col + 1 else @output << str @col += str.length - (str.rindex(?\n) or 0) end end |
#to_s ⇒ Object
Convert this object to its string representation, which is the output gathered so far. TODO: this is rather silly
132 133 134 |
# File 'lib/carat/lisp-format.rb', line 132 def to_s @output end |