Class: PrettyPrint::Text
Instance Attribute Summary (collapse)
-
- (Object) width
readonly
Returns the value of attribute width.
Instance Method Summary (collapse)
- - (Object) add(obj, width)
-
- (Text) initialize
constructor
A new instance of Text.
- - (Object) output(out, output_width)
Constructor Details
- (Text) initialize
A new instance of Text
242 243 244 245 |
# File 'lib/prettyprint.rb', line 242 def initialize @objs = [] @width = 0 end |
Instance Attribute Details
- (Object) width (readonly)
Returns the value of attribute width
246 247 248 |
# File 'lib/prettyprint.rb', line 246 def width @width end |
Instance Method Details
- (Object) add(obj, width)
253 254 255 256 |
# File 'lib/prettyprint.rb', line 253 def add(obj, width) @objs << obj @width += width end |
- (Object) output(out, output_width)
248 249 250 251 |
# File 'lib/prettyprint.rb', line 248 def output(out, output_width) @objs.each {|obj| out << obj} output_width + @width end |