diff options
Diffstat (limited to 'lib/prettyprint.rb')
| -rw-r--r-- | lib/prettyprint.rb | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb index 2a3ca90dc1..44ca5e816f 100644 --- a/lib/prettyprint.rb +++ b/lib/prettyprint.rb @@ -23,16 +23,19 @@ # # == References # Christian Lindig, Strictly Pretty, March 2000, -# http://www.st.cs.uni-sb.de/~lindig/papers/#pretty +# https://lindig.github.io/papers/strictly-pretty-2000.pdf # # Philip Wadler, A prettier printer, March 1998, -# http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier +# https://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier # # == Author # Tanaka Akira <akr@fsij.org> # class PrettyPrint + # The version string + VERSION = "0.2.0" + # This is a convenience method which is same as follows: # # begin @@ -102,7 +105,7 @@ class PrettyPrint # The maximum width of a line, before it is separated in to a newline # - # This defaults to 79, and should be a Fixnum + # This defaults to 79, and should be an Integer attr_reader :maxwidth # The value that is appended to +output+ to add a new line. @@ -110,7 +113,7 @@ class PrettyPrint # This defaults to "\n", and should be String attr_reader :newline - # A lambda or Proc, that takes one argument, of a Fixnum, and returns + # A lambda or Proc, that takes one argument, of an Integer, and returns # the corresponding number of spaces. # # By default this is: @@ -340,7 +343,7 @@ class PrettyPrint # # Arguments: # * +sep+ String of the separator - # * +width+ Fixnum width of the +sep+ + # * +width+ Integer width of the +sep+ # * +q+ parent PrettyPrint object, to base from def initialize(sep, width, q) @obj = sep @@ -484,8 +487,10 @@ class PrettyPrint # It is passed to be similar to a PrettyPrint object itself, by responding to: # * #text # * #breakable + # * #fill_breakable # * #nest # * #group + # * #group_sub # * #flush # * #first? # @@ -519,6 +524,13 @@ class PrettyPrint @output << sep end + # Appends +sep+ to the text to be output. By default +sep+ is ' ' + # + # +width+ argument is here for compatibility. It is a noop argument. + def fill_breakable(sep=' ', width=nil) + @output << sep + end + # Takes +indent+ arg, but does nothing with it. # # Yields to a block. @@ -542,6 +554,15 @@ class PrettyPrint @first.pop end + # Yields to a block for compatibility. + def group_sub # :nodoc: + yield + end + + # Method present for compatibility, but is a noop + def break_outmost_groups # :nodoc: + end + # Method present for compatibility, but is a noop def flush # :nodoc: end |
