class EAAL::Result::ResultElement

result element

Attributes

attribs[RW]
name[RW]
value[RW]

Public Class Methods

new(name, value) click to toggle source
# File lib/eaal/result.rb, line 49
def initialize(name, value)
    self.name = name
    self.value = value
    self.attribs = {}
end
parse_element(prefix, element) click to toggle source

parses an xml element to create either the ResultElement, ResultContainer or Rowset necessary

# File lib/eaal/result.rb, line 69
def self.parse_element(prefix, element)
    if element.name == "rowset" then
        re = EAAL::Rowset.new(prefix, element)
    else
        key = element.name
        if element.children && element.containers.length > 0
            container = ResultContainer.new
            element.containers.each { |celement|
                cel = EAAL::Result::ResultElement.parse_element(prefix, celement)
                if celement.attributes.to_hash.length > 0
                    container.add_element(cel.name, cel)
                else
                    container.add_element(cel.name, cel.value)
                end
            }
            value = container
        else
            # Mainly to filter HTML tags within description element in corporationsheet.
            value = element.inner_html.gsub(/(<|&lt;)(.|\n)*?(>|&gt;)/, "")
        end
        re = ResultElement.new(key, value)
        if element.attributes.to_hash.length > 0
            re.attribs.merge!(element.attributes.to_hash)
            if re.value.respond_to?(:attribs)
                re.value.attribs.merge!(element.attributes.to_hash)
            end
        end
    end
    re
end

Public Instance Methods

add_attrib(key, val) click to toggle source
# File lib/eaal/result.rb, line 55
def add_attrib(key, val)
    self.attribs.merge!({key => val})
end
method_missing(method, *args) click to toggle source
# File lib/eaal/result.rb, line 59
def method_missing(method, *args)
    if self.attribs.has_key?(method.id2name)
        self.attribs[method.id2name]
    else
        self.value.send(method, *args)
    end
end