Class: Ruleby::Core::ReferenceAtom

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

Overview

This kind of atom is used for matching a value that is a variable. For example:

#name == #:your_name

The expression for this atom depends on some other atom.

Direct Known Subclasses

SelfReferenceAtom

Instance Attribute Summary collapse

Attributes inherited from Atom

#proc, #slot, #tag, #template

Instance Method Summary collapse

Constructor Details

#initialize(tag, slot, vars, template, block) ⇒ ReferenceAtom

Returns a new instance of ReferenceAtom.



134
135
136
137
# File 'lib/core/atoms.rb', line 134

def initialize(tag, slot, vars, template, block)
  super(tag, slot, template, block)
  @vars = vars # list of referenced variable names
end

Instance Attribute Details

#varsObject (readonly)

Returns the value of attribute vars.



132
133
134
# File 'lib/core/atoms.rb', line 132

def vars
  @vars
end

Instance Method Details

#==(atom) ⇒ Object



143
144
145
146
147
148
149
# File 'lib/core/atoms.rb', line 143

def ==(atom)      
  ReferenceAtom === atom &&
         @proc == atom.proc && 
         @tag == atom.tag && 
         @vars == atom.vars && 
         @template == atom.template
end

#shareable?(atom) ⇒ Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/core/atoms.rb', line 139

def shareable?(atom)
  false
end

#to_sObject



151
152
153
# File 'lib/core/atoms.rb', line 151

def to_s
  super + ", vars=#{vars.join(',')}"
end