Class: Ruleby::Core::PropertyAtom

Inherits:
Atom
  • Object
show all
Defined in:
lib/core/atoms.rb

Overview

This kind of atom is used to match a simple condition.

For example:

a.person{ |p| p.is_a? Person }

So there are no references to other atoms.

Direct Known Subclasses

EqualsAtom, HeadAtom

Instance Attribute Summary collapse

Attributes inherited from Atom

#proc, #slot, #tag, #template

Instance Method Summary collapse

Methods inherited from Atom

#to_s

Constructor Details

#initialize(tag, slot, template, value, block) ⇒ PropertyAtom

Returns a new instance of PropertyAtom.



41
42
43
44
# File 'lib/core/atoms.rb', line 41

def initialize(tag, slot, template, value, block)
  super(tag,slot,template, block)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



39
40
41
# File 'lib/core/atoms.rb', line 39

def value
  @value
end

Instance Method Details

#==(atom) ⇒ Object



46
47
48
# File 'lib/core/atoms.rb', line 46

def ==(atom)      
  shareable?(atom) && @tag == atom.tag
end

#shareable?(atom) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'lib/core/atoms.rb', line 50

def shareable?(atom)
  PropertyAtom === atom &&
         @slot == atom.slot &&
         @template == atom.template &&
         @proc == atom.proc &&
         @value == atom.value
end