Class: Konjak::Parser
- Inherits:
-
Object
- Object
- Konjak::Parser
- Defined in:
- lib/konjak/parser.rb
Instance Attribute Summary collapse
-
#gtt ⇒ Object
Returns the value of attribute gtt.
Instance Method Summary collapse
-
#initialize(gtt: false) ⇒ Parser
constructor
A new instance of Parser.
- #parse(xml) ⇒ Object
Constructor Details
#initialize(gtt: false) ⇒ Parser
Returns a new instance of Parser.
7 8 9 |
# File 'lib/konjak/parser.rb', line 7 def initialize(gtt: false) @gtt = gtt end |
Instance Attribute Details
#gtt ⇒ Object
Returns the value of attribute gtt.
5 6 7 |
# File 'lib/konjak/parser.rb', line 5 def gtt @gtt end |
Instance Method Details
#parse(xml) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/konjak/parser.rb', line 11 def parse(xml) if gtt # FIXME GTT's tmx store © as © xml = xml.gsub(/&(#\d+|#x[0-9a-fA-F]+|[0-9a-zA-Z]+);/) { "&#{$1};" } # FIXME GTT's tmx store leading space(\u0020) as non-breaking space(\u00A0) xml = xml.gsub("\u00A0", ' ') end doc = Nokogiri::XML.parse(xml) Tmx.new doc end |