In Files

  • prettyprint.rb

Parent

Class/Module Index [+]

Quicksearch

PrettyPrint::SingleLine

PrettyPrint::SingleLine is used by PrettyPrint.singleline_format

It is passed to be similar to a PrettyPrint object itself, by responding to:

but instead, the output has no line breaks

Public Class Methods

new(output, maxwidth=nil, newline=nil) click to toggle source

Create a PrettyPrint::SingleLine object

Arguments:

  • output - String (or similar) to store rendered text. Needs to respond to '<<'

  • maxwidth - Argument position expected to be here for compatibility.

    This argument is a noop.
  • newline - Argument position expected to be here for compatibility.

    This argument is a noop.
 
               # File prettyprint.rb, line 523
def initialize(output, maxwidth=nil, newline=nil)
  @output = output
  @first = [true]
end
            

Public Instance Methods

breakable(sep=' ', width=nil) click to toggle source

Appends sep to the text to be output. By default sep is ‘ ’

width argument is here for compatibility. It is a noop argument.

 
               # File prettyprint.rb, line 538
def breakable(sep=' ', width=nil)
  @output << sep
end
            
first?() click to toggle source

This is used as a predicate, and ought to be called first.

 
               # File prettyprint.rb, line 570
def first?
  result = @first[-1]
  @first[-1] = false
  result
end
            
group(indent=nil, open_obj='', close_obj='', open_width=nil, close_width=nil) click to toggle source

Opens a block for grouping objects to be pretty printed.

Arguments:

  • indent - noop argument. Present for compatibility.

  • open_obj - text appended before the &blok. Default is "

  • close_obj - text appended after the &blok. Default is "

  • open_width - noop argument. Present for compatibility.

  • close_width - noop argument. Present for compatibility.

 
               # File prettyprint.rb, line 557
def group(indent=nil, open_obj='', close_obj='', open_width=nil, close_width=nil)
  @first.push true
  @output << open_obj
  yield
  @output << close_obj
  @first.pop
end
            
text(obj, width=nil) click to toggle source

Add obj to the text to be output.

width argument is here for compatibility. It is a noop argument.

 
               # File prettyprint.rb, line 531
def text(obj, width=nil)
  @output << obj
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus