Class: SbuilderSexp::PrimaryExpression

Inherits:
InfixExpression show all
Defined in:
lib/parser/parser_nodes.rb

Instance Method Summary collapse

Methods inherited from InfixExpression

#expression_val, #operator

Methods inherited from AbstactExpression

#expression_prefix, #expression_val, #has_rhs, #lhs_node, #node_value, #rhs_node, #traverse

Methods inherited from Treetop::Runtime::SyntaxNode

#node_type, #node_value, #recursive_inject, #recursive_inject_parent, #recursive_select, #value

Instance Method Details

#attribute_accessorsAbstactExpression:Array

Access record by field name or by value

Returns:

  • (AbstactExpression:Array)

    to acccess record fields



197
198
199
200
201
202
# File 'lib/parser/parser_nodes.rb', line 197

def attribute_accessors
  deffi = elements.select{ |e| e.is_a?( SbuilderSexp::UnitExpression )}.first
  return unless deffi && !deffi.text_value.empty?
  deffi = deffi.recursive_select( SbuilderSexp::AbstactExpression )
  return deffi
end

#expression_postfixObject

AbstactExpression.travers yield if non-nil



191
192
193
# File 'lib/parser/parser_nodes.rb', line 191

def expression_postfix
  return "has-attribute-accessors" if has_attribute_accessors
end

#expressionsObject

AbstractExpression.traverse: postfix expression does not recurse to UnitExpressions, instead yield block iterates using ‘attribute_accessors’



185
186
187
188
# File 'lib/parser/parser_nodes.rb', line 185

def expressions
  # expressions = recursive_select( SbuilderSexp::AbstactExpression )
  super.select { |e| !e.is_a?(SbuilderSexp::UnitExpression) }
end

#has_attribute_accessorsboolean

Returns true if expression defines record accessor.

Returns:

  • (boolean)

    true if expression defines record accessor



206
207
208
# File 'lib/parser/parser_nodes.rb', line 206

def has_attribute_accessors
  attribute_accessors && attribute_accessors.any?      
end