Class: Norikra::Query::ASTEventPropNode

Inherits:
ASTNode
  • Object
show all
Defined in:
lib/norikra/query/ast.rb

Overview

eventProperty

Instance Attribute Summary

Attributes inherited from ASTNode

#children, #name, #tree

Instance Method Summary collapse

Methods inherited from ASTNode

#child, #find, #initialize, #listup, #to_a

Constructor Details

This class inherits a constructor from Norikra::Query::ASTNode

Instance Method Details

#fields(default_target = nil, known_targets_aliases = []) ⇒ Object



866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
# File 'lib/norikra/query/ast.rb', line 866

def fields(default_target=nil, known_targets_aliases=[])
  props = self.listup('eventPropertyAtomic')
  leading_name = props[0].find('eventPropertyIdent').find('keywordAllowedIdent').child.name

  if props.size > 1 # alias.fieldname or container_fieldname.key.$1 or fieldname.method(...)
    non_calls = props.select{|p| p.children.size == 1 }.map{|p| p.find('eventPropertyIdent').find('keywordAllowedIdent').child.name }
    if known_targets_aliases.include?(leading_name)
      [ {:f => non_calls[1..-1].join("."), :t => leading_name} ]
    else
      [ {:f => non_calls.join("."), :t => default_target} ]
    end
  else # fieldname (default target)
    # ["eventProperty", ["eventPropertyAtomic", ["eventPropertyIdent", ["keywordAllowedIdent", "a"]]]
    [ {:f => leading_name, :t => default_target } ]
  end
end

#nodetype?(*sym) ⇒ Boolean

“‘size.num`”

“eventProperty”, [“eventPropertyAtomic”, [“eventPropertyIdent”, [“keywordAllowedIdent”, “‘size.num`”]]]

Returns:

  • (Boolean)


862
863
864
# File 'lib/norikra/query/ast.rb', line 862

def nodetype?(*sym)
  sym.include?(:prop) || sym.include?(:property)
end