Class: ShellOpts::Grammar::DocNode

Inherits:
Node
  • Object
show all
Defined in:
lib/shellopts/grammar.rb,
lib/shellopts/formatter.rb

Overview

DocNode object has no children but lines.

Direct Known Subclasses

ArgDescr, Brief, Code, Paragraph

Constant Summary

Constants inherited from Node

Node::ALLOWED_PARENTS

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #parent, #token

Instance Method Summary collapse

Methods inherited from Node

#analyzer_error, #ancestors, #dump_ast, #dump_attrs, #dump_idr, #inspect, #parents, #parse, parse, #parser_error, #puts_help, #puts_usage, #remove_arg_descr_nodes, #remove_arg_spec_nodes, #remove_brief_nodes, #traverse

Constructor Details

#initialize(parent, token, text = nil) ⇒ DocNode

Returns a new instance of DocNode.



329
330
331
332
333
# File 'lib/shellopts/grammar.rb', line 329

def initialize(parent, token, text = nil)
  @tokens = [token]
  @text = text
  super(parent, token)
end

Instance Attribute Details

#tokensObject (readonly)

Array of :text tokens. Assigned by the parser



320
321
322
# File 'lib/shellopts/grammar.rb', line 320

def tokens
  @tokens
end

Instance Method Details

#linesObject



325
# File 'lib/shellopts/grammar.rb', line 325

def lines() [text] end

#puts_descrObject



171
# File 'lib/shellopts/formatter.rb', line 171

def puts_descr() puts lines end

#textObject

The text of the node



323
# File 'lib/shellopts/grammar.rb', line 323

def text() @text ||= tokens.map(&:source).join(" ") end

#to_sObject

FIXME



327
# File 'lib/shellopts/grammar.rb', line 327

def to_s() text end