Class: Doc2Text::XmlBasedDocument::XmlNodes::Node
- Inherits:
-
Object
- Object
- Doc2Text::XmlBasedDocument::XmlNodes::Node
show all
- Defined in:
- lib/doc2text/generic_xml_nodes.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parent = nil, attrs = [], prefix = nil, name = nil, markdown_odt_parser = nil) ⇒ Node
Returns a new instance of Node.
14
15
16
17
18
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 14
def initialize(parent = nil, attrs = [], prefix = nil, name = nil, markdown_odt_parser = nil)
@parent, @attrs, @prefix, @name, @xml_parser = parent, attrs, prefix, name, markdown_odt_parser
@children = []
@has_text = false
end
|
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
5
6
7
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 5
def attrs
@attrs
end
|
#children ⇒ Object
Returns the value of attribute children.
5
6
7
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 5
def children
@children
end
|
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 5
def name
@name
end
|
#parent ⇒ Object
Returns the value of attribute parent.
5
6
7
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 5
def parent
@parent
end
|
#prefix ⇒ Object
Returns the value of attribute prefix.
5
6
7
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 5
def prefix
@prefix
end
|
#text ⇒ Object
Returns the value of attribute text.
6
7
8
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 6
def text
@text
end
|
Class Method Details
.inherited(subclass) ⇒ Object
8
9
10
11
12
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 8
def self.inherited(subclass)
def subclass.titleize(tag)
tag.split('-').map(&:capitalize).join
end
end
|
Instance Method Details
#close ⇒ Object
32
33
34
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 32
def close
''
end
|
#delete ⇒ Object
36
37
38
39
40
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 36
def delete
return true unless @children
@children.each { |child| child.delete }
@children = []
end
|
#eql?(object) ⇒ Boolean
42
43
44
45
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 42
def eql?(object)
return false unless object.is_a? Node
object.xml_name == xml_name
end
|
#expand ⇒ Object
59
60
61
62
63
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 59
def expand
expanded = "#{open}#{@children.map(&:expand).join}#{close}"
delete
expanded.clone
end
|
#generic? ⇒ Boolean
47
48
49
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 47
def generic?
instance_of? Node
end
|
#has_text? ⇒ Boolean
24
25
26
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 24
def has_text?
@has_text
end
|
#open ⇒ Object
28
29
30
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 28
def open
''
end
|
#root? ⇒ Boolean
20
21
22
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 20
def root?
!@parent
end
|
#to_s ⇒ Object
55
56
57
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 55
def to_s
"#{xml_name} : #{attrs}"
end
|
#xml_name ⇒ Object
51
52
53
|
# File 'lib/doc2text/generic_xml_nodes.rb', line 51
def xml_name
"#{@prefix}:#{@name}"
end
|