Class: Protobug::Compiler::Builder::Comment
- Inherits:
-
Struct
- Object
- Struct
- Protobug::Compiler::Builder::Comment
- Defined in:
- lib/protobug/compiler/builder.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
Instance Method Summary collapse
- #compact? ⇒ Boolean
- #empty? ⇒ Boolean
-
#render(q) ⇒ Object
rubocop:disable Naming/MethodParameterName.
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment
197 198 199 |
# File 'lib/protobug/compiler/builder.rb', line 197 def comment @comment end |
Instance Method Details
#compact? ⇒ Boolean
219 |
# File 'lib/protobug/compiler/builder.rb', line 219 def compact? = false |
#empty? ⇒ Boolean
218 |
# File 'lib/protobug/compiler/builder.rb', line 218 def empty? = false |
#render(q) ⇒ Object
rubocop:disable Naming/MethodParameterName
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/protobug/compiler/builder.rb', line 198 def render(q) # rubocop:disable Naming/MethodParameterName if comment.start_with?("#") q.text(comment) else prefixed = comment.start_with?(" ") q.group do q.break_parent q.seplist( comment.chomp.gsub(/^/m, prefixed ? "#" : "# ").tap do |s| s.gsub!(/^#\s*$/m, "#") end.each_line(chomp: true), -> { q.breakable_empty } ) do |line| q.text line end end end end |