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
201 202 203 |
# File 'lib/protobug/compiler/builder.rb', line 201 def comment @comment end |
Instance Method Details
#compact? ⇒ Boolean
226 227 228 |
# File 'lib/protobug/compiler/builder.rb', line 226 def compact? false end |
#empty? ⇒ Boolean
222 223 224 |
# File 'lib/protobug/compiler/builder.rb', line 222 def empty? false end |
#render(q) ⇒ Object
rubocop:disable Naming/MethodParameterName
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/protobug/compiler/builder.rb', line 202 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 |