Class: Protobug::Compiler::Builder::Group
- Inherits:
-
Struct
- Object
- Struct
- Protobug::Compiler::Builder::Group
- Includes:
- Protobug::Compiler::Builder
- Defined in:
- lib/protobug/compiler/builder.rb,
lib/protobug/compiler/builder_gen.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#close ⇒ Object
Returns the value of attribute close.
-
#indent ⇒ Object
Returns the value of attribute indent.
-
#items ⇒ Object
Returns the value of attribute items.
-
#multi ⇒ Object
Returns the value of attribute multi.
-
#name ⇒ Object
Returns the value of attribute name.
-
#open ⇒ Object
Returns the value of attribute open.
-
#separator ⇒ Object
Returns the value of attribute separator.
Instance Method Summary collapse
- #_class ⇒ Object
- #_def ⇒ Object
- #_module ⇒ Object
- #append(item) ⇒ Object
- #block(&blk) ⇒ Object
- #comment(text) ⇒ Object
- #compact? ⇒ Boolean
- #empty ⇒ Object
- #empty? ⇒ Boolean
- #identifier(name) ⇒ Object
- #literal(content) ⇒ Object
- #op(operator) ⇒ Object
-
#render(q) ⇒ Object
rubocop:disable Naming/MethodParameterName.
Methods included from Protobug::Compiler::Builder
Instance Attribute Details
#close ⇒ Object
Returns the value of attribute close
94 95 96 |
# File 'lib/protobug/compiler/builder.rb', line 94 def close @close end |
#indent ⇒ Object
Returns the value of attribute indent
94 95 96 |
# File 'lib/protobug/compiler/builder.rb', line 94 def indent @indent end |
#items ⇒ Object
Returns the value of attribute items
94 95 96 |
# File 'lib/protobug/compiler/builder.rb', line 94 def items @items end |
#multi ⇒ Object
Returns the value of attribute multi
94 95 96 |
# File 'lib/protobug/compiler/builder.rb', line 94 def multi @multi end |
#name ⇒ Object
Returns the value of attribute name
94 95 96 |
# File 'lib/protobug/compiler/builder.rb', line 94 def name @name end |
#open ⇒ Object
Returns the value of attribute open
94 95 96 |
# File 'lib/protobug/compiler/builder.rb', line 94 def open @open end |
#separator ⇒ Object
Returns the value of attribute separator
94 95 96 |
# File 'lib/protobug/compiler/builder.rb', line 94 def separator @separator end |
Instance Method Details
#_class ⇒ Object
61 62 63 |
# File 'lib/protobug/compiler/builder_gen.rb', line 61 def _class append Statement.new._class end |
#_def ⇒ Object
65 66 67 |
# File 'lib/protobug/compiler/builder_gen.rb', line 65 def _def append Statement.new._def end |
#_module ⇒ Object
69 70 71 |
# File 'lib/protobug/compiler/builder_gen.rb', line 69 def _module append Statement.new._module end |
#append(item) ⇒ Object
140 141 142 143 |
# File 'lib/protobug/compiler/builder.rb', line 140 def append(item) items << item item end |
#block(&blk) ⇒ Object
106 107 108 |
# File 'lib/protobug/compiler/builder.rb', line 106 def block(&blk) append Statement.new.block(&blk) end |
#comment(text) ⇒ Object
98 99 100 |
# File 'lib/protobug/compiler/builder.rb', line 98 def comment(text) append Statement.new.comment(text) end |
#compact? ⇒ Boolean
151 152 153 |
# File 'lib/protobug/compiler/builder.rb', line 151 def compact? false end |
#empty ⇒ Object
102 103 104 |
# File 'lib/protobug/compiler/builder.rb', line 102 def empty append Statement.new.empty end |
#empty? ⇒ Boolean
145 146 147 148 149 |
# File 'lib/protobug/compiler/builder.rb', line 145 def empty? return false if name != :call && (open || close) items.none? { |item| !item.empty? } end |
#identifier(name) ⇒ Object
110 111 112 |
# File 'lib/protobug/compiler/builder.rb', line 110 def identifier(name) append Statement.new.identifier(name) end |
#literal(content) ⇒ Object
114 115 116 |
# File 'lib/protobug/compiler/builder.rb', line 114 def literal(content) append Statement.new.literal(content) end |
#op(operator) ⇒ Object
118 119 120 |
# File 'lib/protobug/compiler/builder.rb', line 118 def op(operator) append Statement.new.op(operator) end |
#render(q) ⇒ Object
rubocop:disable Naming/MethodParameterName
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/protobug/compiler/builder.rb', line 122 def render(q) # rubocop:disable Naming/MethodParameterName if name == "block" && empty? q.breakable "; " q.text "end" end q.group do q.text open if open q.nest(indent || 0) do write_items(q) end return unless close multi ? q.breakable_force : q.breakable_empty q.text close end end |