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

#deftemplate, #method, #proc, #tag

Instance Method Summary collapse

Constructor Details

#initialize(tag, method, vars, deftemplate, &block) ⇒ ReferenceAtom

Returns a new instance of ReferenceAtom.



107
108
109
110
# File 'lib/core/atoms.rb', line 107

def initialize(tag, method, vars, deftemplate, &block) 
  super(tag, method, deftemplate, &block)
  @vars = vars # list of referenced variable names
end

Instance Attribute Details

#varsObject (readonly)

Returns the value of attribute vars.



105
106
107
# File 'lib/core/atoms.rb', line 105

def vars
  @vars
end

Instance Method Details

#==(atom) ⇒ Object



116
117
118
119
120
121
122
# File 'lib/core/atoms.rb', line 116

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

#shareable?(atom) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/core/atoms.rb', line 112

def shareable?(atom)
  false
end

#to_sObject



124
125
126
# File 'lib/core/atoms.rb', line 124

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