class Wongi::Engine::NccNode

Attributes

partner[RW]

Public Class Methods

new(parent) click to toggle source
Calls superclass method Wongi::Engine::BetaNode::new
# File lib/wongi-engine/beta/ncc_node.rb, line 8
def initialize parent
  super
end

Public Instance Methods

beta_activate(token) click to toggle source
# File lib/wongi-engine/beta/ncc_node.rb, line 12
def beta_activate token
  return if tokens.find { |t| t.parent == token }
  t = Token.new self, token, nil, {}
  t.overlay.add_token(t, self)
  partner.tokens.each do |ncc_token|
    next unless ncc_token.ancestors.find { |a| a.equal? token }
    t.ncc_results << ncc_token
    ncc_token.owner = t
  end
  if t.ncc_results.empty?
    children.each do |child|
      child.beta_activate Token.new( child, t, nil, { } )
    end
  end
end
beta_deactivate(token) click to toggle source
# File lib/wongi-engine/beta/ncc_node.rb, line 28
def beta_deactivate token
  t = tokens.find { |tok| tok.parent == token }
  return unless t
  t.overlay.remove_token(t, self)
  t.deleted!
  partner.tokens.select { |ncc| ncc.owner == t }.each do |ncc_token|
    ncc_token.owner = nil
    t.ncc_results.delete ncc_token
  end
  children.each do |beta|
    beta.tokens.select { |token| token.parent == t }.each do |token|
      beta.beta_deactivate token
    end
  end
end
ncc_activate(token) click to toggle source
# File lib/wongi-engine/beta/ncc_node.rb, line 44
def ncc_activate token
  children.each do |child|
    child.beta_activate Token.new( child, token, nil, { } )
  end
end
ncc_deactivate(token) click to toggle source
# File lib/wongi-engine/beta/ncc_node.rb, line 50
def ncc_deactivate token
  children.each do |beta|
    beta.tokens.select { |t| t.parent == token }.each do |t|
      beta.beta_deactivate t
    end
  end
end
refresh_child(child) click to toggle source
# File lib/wongi-engine/beta/ncc_node.rb, line 58
def refresh_child child
  tokens.each do |token|
    if token.ncc_results.empty?
      child.beta_activate Token.new( child, token, nil, { } )
    end
  end
end