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.



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

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



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

def tokens
  @tokens
end

Instance Method Details

#linesObject



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

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



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

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

#to_sObject

FIXME



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

def to_s() text end