Class: BELParser::Parsers::AST::String

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

Overview

AST node representing a UTF-8 encoded string

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, #child, #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 = {}) ⇒ String

New String AST node.



840
841
842
# File 'lib/bel_parser/parsers/ast/node.rb', line 840

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

Instance Method Details

#string_literalObject

Get the string literal.



845
846
847
# File 'lib/bel_parser/parsers/ast/node.rb', line 845

def string_literal
  children[0]
end

#string_valueObject



849
850
851
852
853
854
855
856
# File 'lib/bel_parser/parsers/ast/node.rb', line 849

def string_value
  return nil if children[0].nil?

  value = children[0].dup
  value.slice!(0)  if value[0]  == '"'
  value.slice!(-1) if value[-1] == '"'
  value
end