Class: Oppen::Config
- Inherits:
-
Object
- Object
- Oppen::Config
- Defined in:
- lib/oppen.rb
Overview
Config.
Instance Attribute Summary collapse
-
#indent_anchor ⇒ Object
Returns the value of attribute indent_anchor.
Class Method Summary collapse
-
.oppen ⇒ Config
Default configuration that provides printing behaviour identical to what's been described by Oppen.
-
.wadler(eager_print: true, trim_trailing_whitespaces: true, upsize_stack: true) ⇒ Config
Configure the printer to behave more like ruby/prettyprint:.
Instance Method Summary collapse
-
#eager_print? ⇒ Boolean
Print groups eagerly.
-
#initialize(eager_print: false, indent_anchor: :end_of_previous_line, trim_trailing_whitespaces: false, upsize_stack: false) ⇒ Config
constructor
A new instance of Config.
- #trim_trailing_whitespaces? ⇒ Boolean
- #upsize_stack? ⇒ Boolean
Constructor Details
#initialize(eager_print: false, indent_anchor: :end_of_previous_line, trim_trailing_whitespaces: false, upsize_stack: false) ⇒ Config
Returns a new instance of Config.
94 95 96 97 98 99 100 |
# File 'lib/oppen.rb', line 94 def initialize(eager_print: false, indent_anchor: :end_of_previous_line, trim_trailing_whitespaces: false, upsize_stack: false) @eager_print = eager_print @indent_anchor = indent_anchor @trim_trailing_whitespaces = trim_trailing_whitespaces @upsize_stack = upsize_stack end |
Instance Attribute Details
#indent_anchor ⇒ Object
Returns the value of attribute indent_anchor.
43 44 45 |
# File 'lib/oppen.rb', line 43 def indent_anchor @indent_anchor end |
Class Method Details
.oppen ⇒ Config
Default configuration that provides printing behaviour identical to what's been described by Oppen.
139 140 141 |
# File 'lib/oppen.rb', line 139 def self.oppen new end |
.wadler(eager_print: true, trim_trailing_whitespaces: true, upsize_stack: true) ⇒ Config
Configure the printer to behave more like ruby/prettyprint:
- groups are printed eagerly (we try to flush on a group's close).
- The indentation is anchored on the left margin.
- Trailing whitespaces are removed.
The name was amusingly chosen in reference to Wadler's work on pretty printing.
155 156 157 158 159 160 161 162 |
# File 'lib/oppen.rb', line 155 def self.wadler(eager_print: true, trim_trailing_whitespaces: true, upsize_stack: true) new( eager_print:, indent_anchor: :current_offset, trim_trailing_whitespaces:, upsize_stack:, ) end |
Instance Method Details
#eager_print? ⇒ Boolean
Print groups eagerly.
129 |
# File 'lib/oppen.rb', line 129 def eager_print? = @eager_print |
#trim_trailing_whitespaces? ⇒ Boolean
131 |
# File 'lib/oppen.rb', line 131 def trim_trailing_whitespaces? = @trim_trailing_whitespaces |
#upsize_stack? ⇒ Boolean
133 |
# File 'lib/oppen.rb', line 133 def upsize_stack? = @upsize_stack |