Class: BELParser::Parsers::AST::Object

Inherits:
Node show all
Defined in:
lib/bel_parser/parsers/ast/node.rb

Overview

AST node representing the object of a statement.

Instance Attribute Summary

Attributes inherited from Node

#character_range, #complete, #line_number

Attributes inherited from AST::Node

#children, #hash, #type

Instance Method Summary collapse

Methods inherited from Node

#add_syntax_error, #append, #children?, #complete?, #concat, #first_child, #fourth_child, #freeze, #incomplete?, #num_children, #range_end, #range_start, #second_child, #syntax_errors, #third_child, #traverse, #updated

Methods inherited from AST::Node

#==, #append, #concat, #dup, #eql?, #inspect, #to_a, #to_ast, #to_bel, #to_s, #to_sexp, #updated

Methods included from BELParser::Parsers

#serialize

Constructor Details

#initialize(children = [], properties = {}) ⇒ Object

New Object AST node.



810
811
812
# File 'lib/bel_parser/parsers/ast/node.rb', line 810

def initialize(children = [], properties = {})
  super(Object.ast_type, children, properties)
end

Instance Method Details

#childObject

Get the Term or Statement child.



825
826
827
# File 'lib/bel_parser/parsers/ast/node.rb', line 825

def child
  children[0]
end

#statement?Boolean

Does the object have a Statement child?

Returns:

  • (Boolean)


820
821
822
# File 'lib/bel_parser/parsers/ast/node.rb', line 820

def statement?
  children[0].is_a?(Statement)
end

#term?Boolean

Does the object have a Term child?

Returns:

  • (Boolean)


815
816
817
# File 'lib/bel_parser/parsers/ast/node.rb', line 815

def term?
  children[0].is_a?(Term)
end