Class: DoctorNinja::Parsers::Run
- Inherits:
-
Base
- Object
- Base
- DoctorNinja::Parsers::Run
show all
- Defined in:
- lib/doctor_ninja/parsers/run.rb
Constant Summary
collapse
- @@available_tags =
["b", "u", "i"]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #parse_children
Class Method Details
.applicable_to?(node) ⇒ Boolean
6
7
8
|
# File 'lib/doctor_ninja/parsers/run.rb', line 6
def self.applicable_to?(node)
node.name == "r"
end
|
Instance Method Details
#parse ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/doctor_ninja/parsers/run.rb', line 10
def parse
tag = nil
if @node.xpath(".//w:rPr/w:b").length > 0
tag = "b"
end
tags.inject(parse_children){|text,tag| "<#{tag}>#{text}</#{tag}>"}
end
|
19
20
21
22
23
|
# File 'lib/doctor_ninja/parsers/run.rb', line 19
def tags
@node.xpath("./w:rPr").children
.map{|n| n.name}
.select{|n| @@available_tags.include? n}
end
|