class Sekken::XS::BaseType

Attributes

node[R]

Public Class Methods

new(node, schemas, schema = {}) click to toggle source
# File lib/sekken/xs/types.rb, line 6
def initialize(node, schemas, schema = {})
  @node = node
  @schemas = schemas
  @schema = schema
end

Public Instance Methods

[](key) click to toggle source
# File lib/sekken/xs/types.rb, line 14
def [](key)
  @node[key]
end
children() click to toggle source
# File lib/sekken/xs/types.rb, line 22
def children
  @children ||= @node.element_children.map { |child| XS.build(child, @schemas, @schema) }
end
collect_attributes(memo = []) click to toggle source
# File lib/sekken/xs/types.rb, line 38
def collect_attributes(memo = [])
  children.each do |child|
    if child.kind_of? Attribute
      memo << child
    else
      memo = child.collect_attributes(memo)
    end
  end

  memo
end
collect_child_elements(memo = []) click to toggle source
# File lib/sekken/xs/types.rb, line 26
def collect_child_elements(memo = [])
  children.each do |child|
    if child.kind_of? Element
      memo << child
    else
      memo = child.collect_child_elements(memo)
    end
  end

  memo
end
empty?() click to toggle source
# File lib/sekken/xs/types.rb, line 18
def empty?
  children.empty? || children.first.empty?
end
inspect() click to toggle source
# File lib/sekken/xs/types.rb, line 50
def inspect
  attributes = @node.attributes.
    inject({}) { |memo, (k, attr)| memo[k.to_s] = attr.value; memo }.
    map { |i| "%s=\"%s\"" % i }.
    join(' ')
  "<%s %s>" % [self.class, attributes]
end