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.



244
245
246
247
# File 'lib/prettyprint.rb', line 244

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

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width



248
249
250
# File 'lib/prettyprint.rb', line 248

def width
  @width
end

Instance Method Details

#add(obj, width) ⇒ Object



255
256
257
258
# File 'lib/prettyprint.rb', line 255

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

#output(out, output_width) ⇒ Object



250
251
252
253
# File 'lib/prettyprint.rb', line 250

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