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
'0.9.7'
Class Method Summary collapse
-
.begin_consistent(offset: 2) ⇒ Oppen::Token::Begin
A new consistent Begin token.
-
.begin_inconsistent(offset: 2) ⇒ Oppen::Token::Begin
A new inconsistent Begin token.
-
.break(str = ' ', line_continuation: '', offset: 0, width: str.length) ⇒ Oppen::Token::Break
A new Break token.
-
.end ⇒ Oppen::Token::End
A new End token.
-
.eof ⇒ Oppen::Token::EOF
A new EOF token.
-
.line_break(line_continuation: '', offset: 0) ⇒ Oppen::Token::LineBreak
A new LineBreak token.
-
.print(config: Config.oppen, space: ' ', new_line: "\n", out: StringIO.new, tokens: [], width: 80) ⇒ String
Entry point of the pretty printer.
-
.string(value, width: value.length) ⇒ Oppen::Token::String
A new String token.
-
.whitespace(value) ⇒ Oppen::Token::Whitespace
A new Whitespace token.
Methods included from Mixins
tokens_to_wadler, upsize_circular_array
Class Method Details
.begin_consistent(offset: 2) ⇒ Oppen::Token::Begin
Returns a new consistent Begin token.
146 147 148 |
# File 'lib/oppen.rb', line 146 def self.begin_consistent(offset: 2) Token::Begin.new(break_type: Token::BreakType::CONSISTENT, offset:) end |
.begin_inconsistent(offset: 2) ⇒ Oppen::Token::Begin
Returns a new inconsistent Begin token.
153 154 155 |
# File 'lib/oppen.rb', line 153 def self.begin_inconsistent(offset: 2) Token::Begin.new(break_type: Token::BreakType::INCONSISTENT, offset:) end |
.break(str = ' ', line_continuation: '', offset: 0, width: str.length) ⇒ Oppen::Token::Break
Returns a new Break token.
131 132 133 |
# File 'lib/oppen.rb', line 131 def self.break(str = ' ', line_continuation: '', offset: 0, width: str.length) Token::Break.new(str, width:, line_continuation:, offset:) end |
.end ⇒ Oppen::Token::End
Returns a new End token.
158 159 160 |
# File 'lib/oppen.rb', line 158 def self.end Token::End.new end |
.eof ⇒ Oppen::Token::EOF
Returns a new EOF token.
163 164 165 |
# File 'lib/oppen.rb', line 163 def self.eof Token::EOF.new end |
.line_break(line_continuation: '', offset: 0) ⇒ Oppen::Token::LineBreak
Returns a new LineBreak token.
139 140 141 |
# File 'lib/oppen.rb', line 139 def self.line_break(line_continuation: '', offset: 0) Token::LineBreak.new(line_continuation:, offset:) end |
.print(config: Config.oppen, space: ' ', new_line: "\n", out: StringIO.new, tokens: [], width: 80) ⇒ String
Entry point of the pretty printer.
30 31 32 33 34 35 36 37 |
# File 'lib/oppen.rb', line 30 def self.print(config: Config.oppen, space: ' ', new_line: "\n", out: StringIO.new, 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) ⇒ Oppen::Token::String
Returns a new String token.
114 115 116 |
# File 'lib/oppen.rb', line 114 def self.string(value, width: value.length) Token::String.new(value, width:) end |
.whitespace(value) ⇒ Oppen::Token::Whitespace
Returns a new Whitespace token.
121 122 123 |
# File 'lib/oppen.rb', line 121 def self.whitespace(value) Token::Whitespace.new(value, width: value.bytesize) end |