class Oozby::Element

Represent an oozby element

Attributes

data[R]
siblings[R]

Public Class Methods

new(hash) click to toggle source
# File lib/oozby/element.rb, line 5
def initialize hash
  @data = hash
  @siblings = nil #parent_array
end

Public Instance Methods

>(other) click to toggle source

include the next thing as a child of this thing

# File lib/oozby/element.rb, line 11
def > other
  raise "Can only combine an Oozby::Element to another Oozby::Element" unless other.respond_to? :to_oozby_element
  other.to_oozby_element.abduct self.children
  other
end
abduct(into) click to toggle source

add this element to the end of supplied array

# File lib/oozby/element.rb, line 18
def abduct into
  @siblings.delete self if @siblings # remove from current location
  @siblings = into # our new location is here
  into.push self # append ourselves to the new parent
end
index() click to toggle source
# File lib/oozby/element.rb, line 24
def index
  @siblings.index(self)
end
method_missing(name, *args, &proc) click to toggle source
Calls superclass method
# File lib/oozby/element.rb, line 47
def method_missing name, *args, &proc
  if @data.respond_to? name
    @data.send(name, *args, &proc)
  else
    super
  end
end
to_h() click to toggle source
# File lib/oozby/element.rb, line 61
def to_h
  @data
end
to_oozby_element() click to toggle source
# File lib/oozby/element.rb, line 65
def to_oozby_element
  self
end
to_s() click to toggle source
# File lib/oozby/element.rb, line 55
def to_s
  x = args.map { |x| x.inspect }
  named_args.each { |name, value| x.push "#{name}: #{value.inspect}"}
  "#{method}(#{x.join(', ')})"
end