Class: MiniKraken::Core::Association
- Inherits:
-
Object
- Object
- MiniKraken::Core::Association
- Defined in:
- lib/mini_kraken/core/association.rb
Overview
A record that a given variable is associated with a value.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#i_name ⇒ String
Internal name of variable being associated the value.
-
#value ⇒ Term
readonly
The MiniKraken value associated with the variable.
Instance Method Summary collapse
-
#dependencies(ctx) ⇒ Array<String>
The i_names of direct dependent variables.
-
#floating?(ctx) ⇒ Boolean
Is the associated value floating, that is, it does contain a variable that is either unbound or floating?.
-
#initialize(aVariable, aValue) ⇒ Association
constructor
A new instance of Association.
-
#pinned?(ctx) ⇒ Boolean
Is the associated value pinned, that is, doesn’t contain an unbound or floating variable?.
Constructor Details
#initialize(aVariable, aValue) ⇒ Association
Returns a new instance of Association.
15 16 17 18 19 20 |
# File 'lib/mini_kraken/core/association.rb', line 15 def initialize(aVariable, aValue) a_name = aVariable.respond_to?(:i_name) ? aVariable.i_name : aVariable @i_name = validated_name(a_name) @value = aValue @dependencies = nil end |
Instance Attribute Details
#i_name ⇒ String
Returns internal name of variable being associated the value.
8 9 10 |
# File 'lib/mini_kraken/core/association.rb', line 8 def i_name @i_name end |
#value ⇒ Term (readonly)
Returns the MiniKraken value associated with the variable.
11 12 13 |
# File 'lib/mini_kraken/core/association.rb', line 11 def value @value end |
Instance Method Details
#dependencies(ctx) ⇒ Array<String>
Returns The i_names of direct dependent variables.
40 41 42 43 44 45 |
# File 'lib/mini_kraken/core/association.rb', line 40 def dependencies(ctx) @dependencies ||= value.dependencies(ctx) raise StandardError unless @dependencies.kind_of?(Set) || @dependencies.kind_of?(NilClass) @dependencies end |
#floating?(ctx) ⇒ Boolean
Is the associated value floating, that is, it does contain a variable that is either unbound or floating?
26 27 28 |
# File 'lib/mini_kraken/core/association.rb', line 26 def floating?(ctx) value.floating?(ctx) end |
#pinned?(ctx) ⇒ Boolean
Is the associated value pinned, that is, doesn’t contain an unbound or floating variable?
34 35 36 37 |
# File 'lib/mini_kraken/core/association.rb', line 34 def pinned?(ctx) @pinned ||= value.pinned?(ctx) @pinned end |