class SlideField::ObjectData

Attributes

children[R]
context[RW]
include_path[RW]
loc[R]
parent[RW]
type[R]

Public Class Methods

new(type, loc) click to toggle source
# File lib/slidefield/object_data.rb, line 5
def initialize(type, loc)
  @type = type
  @loc = loc
  @variables = {}
  @children = []
end

Public Instance Methods

<<(child) click to toggle source
# File lib/slidefield/object_data.rb, line 47
def <<(child)
  child.parent = self
  @children << child
end
[](selector) click to toggle source
# File lib/slidefield/object_data.rb, line 52
def [](selector)
  @children.select {|o| o.type == selector }
end
ancestor(selector) click to toggle source
# File lib/slidefield/object_data.rb, line 56
def ancestor(selector)
  p = @parent
  while p
    return p if p.type == selector
    p = p.parent
  end
  nil
end
context_string() click to toggle source
# File lib/slidefield/object_data.rb, line 65
def context_string
  array = [@context]
  parent = @parent
  while parent
    array.unshift parent.context unless array.first == parent.context
    parent = parent.parent
  end
  "[#{array.join '] ['}]"
end
get(var) click to toggle source
# File lib/slidefield/object_data.rb, line 23
def get(var)
  if has? var
    @variables[var][1]
  elsif parent
    parent.get var
  end
end
has?(var) click to toggle source
# File lib/slidefield/object_data.rb, line 12
def has?(var)
  @variables.has_key? var
end
rules() click to toggle source
# File lib/slidefield/object_data.rb, line 75
def rules
  SlideField::ObjectRules[@type]
end
set(var, val, loc = nil, type = nil) click to toggle source
# File lib/slidefield/object_data.rb, line 16
def set(var, val, loc = nil, type = nil)
  loc ||= var_loc var
  type ||= var_type var

  @variables[var] = [type, val, loc]
end
var_loc(var) click to toggle source
# File lib/slidefield/object_data.rb, line 39
def var_loc(var)
  if has? var
    @variables[var][2] 
  elsif parent
    parent.var_loc var
  end
end
var_type(var) click to toggle source
# File lib/slidefield/object_data.rb, line 31
def var_type(var)
  if has? var
    @variables[var][0] 
  elsif parent
    parent.var_type var
  end
end