Class: Mullet::HTML::Parser::OpenElement
- Inherits:
-
Object
- Object
- Mullet::HTML::Parser::OpenElement
- Defined in:
- lib/mullet/html/parser/open_element.rb
Overview
Element where the parser has seen the start tag but not yet seen the end tag.
Constant Summary collapse
- XMLNS_ATTRIBUTE =
'xmlns'- XMLNS_ATTRIBUTE_PREFIX =
XMLNS_ATTRIBUTE + ':'
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#local_name ⇒ Object
readonly
Returns the value of attribute local_name.
-
#namespace_declarations ⇒ Object
readonly
Returns the value of attribute namespace_declarations.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#qualified_name ⇒ Object
readonly
Returns the value of attribute qualified_name.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(parent, qualified_name, raw_attributes) ⇒ OpenElement
constructor
A new instance of OpenElement.
- #resolve_prefix_to_uri(prefix) ⇒ Object
Constructor Details
#initialize(parent, qualified_name, raw_attributes) ⇒ OpenElement
Returns a new instance of OpenElement.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mullet/html/parser/open_element.rb', line 17 def initialize(parent, qualified_name, raw_attributes) # namespace prefix to URI map @namespace_declarations = Hash.new() @parent = parent process_namespace_declarations(raw_attributes) @qualified_name = qualified_name @prefix, @local_name = extract_prefix_and_local_name(qualified_name) @uri = resolve_prefix_to_uri(@prefix) @attributes = to_namespace_aware_attributes(raw_attributes) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
15 16 17 |
# File 'lib/mullet/html/parser/open_element.rb', line 15 def attributes @attributes end |
#local_name ⇒ Object (readonly)
Returns the value of attribute local_name.
14 15 16 |
# File 'lib/mullet/html/parser/open_element.rb', line 14 def local_name @local_name end |
#namespace_declarations ⇒ Object (readonly)
Returns the value of attribute namespace_declarations.
15 16 17 |
# File 'lib/mullet/html/parser/open_element.rb', line 15 def namespace_declarations @namespace_declarations end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
14 15 16 |
# File 'lib/mullet/html/parser/open_element.rb', line 14 def parent @parent end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
14 15 16 |
# File 'lib/mullet/html/parser/open_element.rb', line 14 def prefix @prefix end |
#qualified_name ⇒ Object (readonly)
Returns the value of attribute qualified_name.
14 15 16 |
# File 'lib/mullet/html/parser/open_element.rb', line 14 def qualified_name @qualified_name end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
14 15 16 |
# File 'lib/mullet/html/parser/open_element.rb', line 14 def uri @uri end |
Instance Method Details
#resolve_prefix_to_uri(prefix) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/mullet/html/parser/open_element.rb', line 31 def resolve_prefix_to_uri(prefix) uri = @namespace_declarations.fetch(prefix, nil) if uri == nil && @parent != nil return @parent.resolve_prefix_to_uri(prefix) end return uri end |