Class: PrettyPrint::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/prettyprint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeText

Returns a new instance of Text.



260
261
262
263
# File 'lib/prettyprint.rb', line 260

def initialize
  @objs = []
  @width = 0
end

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width



264
265
266
# File 'lib/prettyprint.rb', line 264

def width
  @width
end

Instance Method Details

#add(obj, width) ⇒ Object



271
272
273
274
# File 'lib/prettyprint.rb', line 271

def add(obj, width)
  @objs << obj
  @width += width
end

#output(out, output_width) ⇒ Object



266
267
268
269
# File 'lib/prettyprint.rb', line 266

def output(out, output_width)
  @objs.each {|obj| out << obj}
  output_width + @width
end