Class: BabelBridge::TerminalNode

Inherits:
Node
  • Object
show all
Defined in:
lib/babel_bridge/nodes/terminal_node.rb

Overview

not subclassed

Instance Attribute Summary collapse

Attributes inherited from Node

#delimiter, #many_delimiter, #match_length, #offset, #parent, #parser, #src

Instance Method Summary collapse

Methods inherited from Node

#column, #init_line_column, #length, #line, #match_range, #node_init, #node_path, #offset_after_match, #on_matched, #onlychildren_list, #parent_list, #path_string, #relative_class_name, #relative_source_file, #remaining_src, #source_file, #text, #to_s, #to_sym

Constructor Details

#initialize(parent, range, pattern) ⇒ TerminalNode

Returns a new instance of TerminalNode.



12
13
14
15
16
17
# File 'lib/babel_bridge/nodes/terminal_node.rb', line 12

def initialize(parent,range,pattern)
  node_init(parent)
  self.offset = range.min
  self.match_length = range.max-range.min
  self.pattern = pattern
end

Instance Attribute Details

#patternObject

Returns the value of attribute pattern.



11
12
13
# File 'lib/babel_bridge/nodes/terminal_node.rb', line 11

def pattern
  @pattern
end

Instance Method Details

#inspect(options = {}) ⇒ Object



19
20
21
# File 'lib/babel_bridge/nodes/terminal_node.rb', line 19

def inspect(options={})
  "#{text.inspect}" unless !options[:verbose] && text[/^\s*$/] # if only show whitespace matches if verbose
end

#matchesObject



23
# File 'lib/babel_bridge/nodes/terminal_node.rb', line 23

def matches; []; end