class WikiThat::Element

Elements are precursors to the final document elements @author Bryan T. Meyers

Attributes

attributes[R]
children[R]
type[R]
value[RW]

Public Class Methods

new(type, value = nil) click to toggle source

Create a new element

@param [Symbol] type the type for this Element @param [Object] value optional value for this Element @return [Element] a newly created Element

# File lib/wiki-that/parser/elements/element.rb, line 29
def initialize(type, value = nil)
  @attributes = {}
  @children   = []
  @type       = type
  @value      = value
end

Public Instance Methods

add_child(child) click to toggle source

Add a child element to this element

@param [Element] child the child element

# File lib/wiki-that/parser/elements/element.rb, line 54
def add_child(child)
  @children.push(child)
end
add_children(*children) click to toggle source

Add multiple child elements to this element

@param [Element] children the child elements

# File lib/wiki-that/parser/elements/element.rb, line 63
def add_children(*children)
  children.each do |child|
    @children.push(child)
  end
end
set_attribute(name, value) click to toggle source

Set an attribute for this element

@param [String] name the name of the attribute @param [String] value the string value of the attribute

# File lib/wiki-that/parser/elements/element.rb, line 45
def set_attribute(name, value)
  @attributes[name] = value
end