Class: Ruleby::Core::HeadAtom

Inherits:
PropertyAtom show all
Defined in:
lib/core/atoms.rb

Overview

This kind of atom is used to match a class type. For example:

'For each Person as :p'

It is only used at the start of a pattern.

Constant Summary collapse

HEAD_EQUAL_PROC =
lambda {|t, c| t == c}
HEAD_INHERITS_PROC =
lambda {|t, c| t === c}

Instance Attribute Summary

Attributes inherited from PropertyAtom

#value

Attributes inherited from Atom

#proc, #slot, #tag, #template

Instance Method Summary collapse

Methods inherited from PropertyAtom

#==

Methods inherited from Atom

#to_s

Constructor Details

#initialize(tag, template) ⇒ HeadAtom



112
113
114
115
116
117
118
# File 'lib/core/atoms.rb', line 112

def initialize(tag, template)
  if template.mode == :equals
    super tag, :class, template, template.clazz, HEAD_EQUAL_PROC
  elsif template.mode == :inherits
    super tag, :class, template, template.clazz, HEAD_INHERITS_PROC
  end
end

Instance Method Details

#shareable?(atom) ⇒ Boolean



120
121
122
# File 'lib/core/atoms.rb', line 120

def shareable?(atom)
  HeadAtom === atom && @template == atom.template
end