class Threatinator::Parsers::XML::NodeBuilder

Public Class Methods

new(name, attributes) click to toggle source
# File lib/threatinator/parsers/xml/node_builder.rb, line 7
def initialize(name, attributes)
  @name = name
  @attributes = {}
  @children = []
  @text = ""

  unless attributes.empty?
    attributes.each { |attr| self.add_attribute(attr.localname, attr.value) }
  end
end

Public Instance Methods

add_attribute(name, value) click to toggle source
# File lib/threatinator/parsers/xml/node_builder.rb, line 22
def add_attribute(name, value)
  @attributes[name.to_sym] = value
end
add_child(node) click to toggle source
# File lib/threatinator/parsers/xml/node_builder.rb, line 26
def add_child(node)
  @children << node
end
append_text(chars) click to toggle source
# File lib/threatinator/parsers/xml/node_builder.rb, line 18
def append_text(chars)
  @text << chars
end
build() click to toggle source
# File lib/threatinator/parsers/xml/node_builder.rb, line 30
def build
  Threatinator::Parsers::XML::Node.new(@name, 
                                       attrs: @attributes, 
                                       text: @text.strip, 
                                       children: @children)
end