Module: Oppen
- Extended by:
- Mixins
- Defined in:
- lib/oppen.rb,
lib/oppen/token.rb,
lib/oppen/mixins.rb,
lib/wadler/print.rb,
lib/oppen/printer.rb,
lib/oppen/version.rb,
lib/oppen/scan_stack.rb,
lib/oppen/print_stack.rb
Overview
Oppen.
Defined Under Namespace
Modules: Mixins Classes: Config, PrintStack, Printer, ScanStack, Token, Wadler
Constant Summary collapse
- VERSION =
Oppen version
'1.0.0'
Class Method Summary collapse
-
.begin_consistent(offset: 2) ⇒ Token::Begin
In a consistent group, the presence of a new line inside the group will propagate to the other Break tokens in the group causing them all to act as a new line.
-
.begin_inconsistent(offset: 2) ⇒ Token::Begin
In an inconsistent group, the presence of a new line inside the group will not propagate to the other Break tokens in the group letting them decide if they need to act as a new line or not.
-
.break(str = ' ', line_continuation: '', offset: 0, width: str.length) ⇒ Token::Break
A new Break token.
-
.end ⇒ Token::End
A new End token.
-
.eof ⇒ Token::EOF
A new EOF token.
-
.line_break(line_continuation: '', offset: 0) ⇒ Token::LineBreak
A new LineBreak token.
-
.print(config: Config.oppen, new_line: "\n", out: StringIO.new, space: ' ', tokens: [], width: 80) ⇒ String
Entry point of the pretty printer.
-
.string(value, width: value.length) ⇒ Token::String
A new String token.
-
.whitespace(value) ⇒ Token::Whitespace
A new Whitespace token.
Methods included from Mixins
Class Method Details
.begin_consistent(offset: 2) ⇒ Token::Begin
In a consistent group, the presence of a new line inside the group will propagate to the other Break tokens in the group causing them all to act as a new line.
234 235 236 |
# File 'lib/oppen.rb', line 234 def self.begin_consistent(offset: 2) Token::Begin.new(break_type: :consistent, offset:) end |
.begin_inconsistent(offset: 2) ⇒ Token::Begin
In an inconsistent group, the presence of a new line inside the group will not propagate to the other Break tokens in the group letting them decide if they need to act as a new line or not.
253 254 255 |
# File 'lib/oppen.rb', line 253 def self.begin_inconsistent(offset: 2) Token::Begin.new(break_type: :inconsistent, offset:) end |
.break(str = ' ', line_continuation: '', offset: 0, width: str.length) ⇒ Token::Break
Returns a new Break token.
198 199 200 |
# File 'lib/oppen.rb', line 198 def self.break(str = ' ', line_continuation: '', offset: 0, width: str.length) Token::Break.new(str, width:, line_continuation:, offset:) end |
.end ⇒ Token::End
Returns a new End token.
258 259 260 |
# File 'lib/oppen.rb', line 258 def self.end Token::End.new end |
.eof ⇒ Token::EOF
Returns a new EOF token.
263 264 265 |
# File 'lib/oppen.rb', line 263 def self.eof Token::EOF.new end |
.line_break(line_continuation: '', offset: 0) ⇒ Token::LineBreak
Returns a new LineBreak token.
211 212 213 |
# File 'lib/oppen.rb', line 211 def self.line_break(line_continuation: '', offset: 0) Token::LineBreak.new(line_continuation:, offset:) end |
.print(config: Config.oppen, new_line: "\n", out: StringIO.new, space: ' ', tokens: [], width: 80) ⇒ String
Entry point of the pretty printer.
32 33 34 35 36 37 38 39 |
# File 'lib/oppen.rb', line 32 def self.print(config: Config.oppen, new_line: "\n", out: StringIO.new, space: ' ', tokens: [], width: 80) printer = Printer.new width, new_line, config, space, out tokens.each do |token| printer.print token end printer.output end |
.string(value, width: value.length) ⇒ Token::String
Returns a new String token.
174 175 176 |
# File 'lib/oppen.rb', line 174 def self.string(value, width: value.length) Token::String.new(value, width:) end |
.whitespace(value) ⇒ Token::Whitespace
Returns a new Whitespace token.
179 180 181 |
# File 'lib/oppen.rb', line 179 def self.whitespace(value) Token::Whitespace.new(value, width: value.bytesize) end |