Class: MiniKraken::Core::AssociationCopy

Inherits:
Association show all
Defined in:
lib/mini_kraken/core/association_copy.rb

Overview

A specialized association that bind a variable to a value from another association.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aVariable, anAssoc) ⇒ AssociationCopy

Returns a new instance of AssociationCopy.

Parameters:

  • aVariable (Variable, String)

    A variable or its internal name.

  • anAssoc (Association)

    an association that shares its value.



18
19
20
21
# File 'lib/mini_kraken/core/association_copy.rb', line 18

def initialize(aVariable, anAssoc)
  super(aVariable, nil)
  @source = anAssoc
end

Instance Attribute Details

#i_nameString

Returns internal name of variable being associated the value.

Returns:

  • (String)

    internal name of variable being associated the value.



11
12
13
# File 'lib/mini_kraken/core/association_copy.rb', line 11

def i_name
  @i_name
end

#sourceAssociation (readonly)

Returns the association from which the value is shared.

Returns:

  • (Association)

    the association from which the value is shared.



14
15
16
# File 'lib/mini_kraken/core/association_copy.rb', line 14

def source
  @source
end

Instance Method Details

#dependencies(ctx) ⇒ Array<String>

Returns The i_names of direct dependent variables.

Returns:

  • (Array<String>)

    The i_names of direct dependent variables



45
46
47
# File 'lib/mini_kraken/core/association_copy.rb', line 45

def dependencies(ctx)
   source.dependencies(ctx)
end

#floating?(ctx) ⇒ Boolean

Is the associated value floating, that is, it does contain a variable that is either unbound or floating?

Parameters:

Returns:

  • (Boolean)


27
28
29
# File 'lib/mini_kraken/core/association_copy.rb', line 27

def floating?(ctx)
  source.floating?(ctx)
end

#pinned?(ctx) ⇒ Boolean

Is the associated value pinned, that is, doesn’t contain an unbound or floating variable?

Parameters:

Returns:

  • (Boolean)


35
36
37
# File 'lib/mini_kraken/core/association_copy.rb', line 35

def pinned?(ctx)
  source.pinned?(ctx)
end

#valueTerm

Returns the MiniKraken value associated with the variable.

Returns:

  • (Term)

    the MiniKraken value associated with the variable



40
41
42
# File 'lib/mini_kraken/core/association_copy.rb', line 40

def value
  source.value
end