Class: Arachni::Parser::Nodes::Element

Inherits:
Base show all
Includes:
WithAttributes, WithChildren
Defined in:
lib/arachni/parser/nodes/element.rb,
lib/arachni/parser/nodes/element/with_attributes.rb,
lib/arachni/parser/nodes/element/with_attributes/attributes.rb

Defined Under Namespace

Modules: WithAttributes

Instance Attribute Summary collapse

Attributes inherited from Base

#document, #parent

Instance Method Summary collapse

Methods included from WithAttributes

#[], #[]=, #attributes

Methods included from WithChildren

#<<, #children, #text

Methods included from WithChildren::Search

#descendants, #nodes_by_attribute_name, #nodes_by_attribute_name_and_value, #nodes_by_class, #nodes_by_name, #nodes_by_names, #traverse

Constructor Details

#initialize(name) ⇒ Element

Returns a new instance of Element.



24
25
26
# File 'lib/arachni/parser/nodes/element.rb', line 24

def initialize( name )
    @name = name.downcase.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/arachni/parser/nodes/element.rb', line 22

def name
  @name
end

Instance Method Details

#to_html(indentation = 2, level = 0) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/arachni/parser/nodes/element.rb', line 28

def to_html( indentation = 2, level = 0 )
    indent = ' ' * (indentation * level)

    html = "#{indent}<#{name}"

    attributes.each do |k, v|
        html << " #{k}=#{v.inspect}"
    end

    html << ">\n"
    children.each do |node|
        html << node.to_html( indentation, level + 1  )
    end
    html << "#{indent}</#{name}>\n"
end