Class: Ruleby::Core::HeadAtom
- Inherits:
-
PropertyAtom
- Object
- Atom
- PropertyAtom
- Ruleby::Core::HeadAtom
- 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
Attributes inherited from Atom
Instance Method Summary collapse
-
#initialize(tag, template) ⇒ HeadAtom
constructor
A new instance of HeadAtom.
- #shareable?(atom) ⇒ Boolean
Methods inherited from PropertyAtom
Methods inherited from Atom
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 |