Class: LLT::Review::Alignment::Parser::OxHandler
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- LLT::Review::Alignment::Parser::OxHandler
- Includes:
- Helper, Helpers::Parsing::Helper
- Defined in:
- lib/llt/review/alignment/parser/ox_handler.rb
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #end_element(name) ⇒ Object
- #parse(data) ⇒ Object
- #start_element(name) ⇒ Object
- #text(value) ⇒ Object
Methods included from Helper
Methods included from Helpers::Parsing::Helper
Instance Method Details
#attr(name, value) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/llt/review/alignment/parser/ox_handler.rb', line 41 def attr(name, value) if @in_word case name when :n then register_word(value) when :nrefs then register_translation(value) unless @original end else case when @in_wds then set_orig_or_translation(value) if name == :lnum when @in_sentence then register_sentence(value) if name == :id when @in_language then set_languages(name, value) end end end |
#end_element(name) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/llt/review/alignment/parser/ox_handler.rb', line 30 def end_element(name) case name when :w then @in_word = false when :text then @in_text = false when :refs then @in_refs = false when :wds then @in_wds = false when :sentence then @in_sentence = false when :language then @in_language = false end end |
#parse(data) ⇒ Object
10 11 12 |
# File 'lib/llt/review/alignment/parser/ox_handler.rb', line 10 def parse(data) Ox.sax_parse(self, data) end |
#start_element(name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/llt/review/alignment/parser/ox_handler.rb', line 14 def start_element(name) if @in_word case name when :text then @in_text = true when :refs then @in_refs = true end else case name when :w then @in_word = true when :wds then @in_wds = true when :sentence then @in_sentence = true when :language then @in_language = true end end end |
#text(value) ⇒ Object
56 57 58 |
# File 'lib/llt/review/alignment/parser/ox_handler.rb', line 56 def text(value) set_text(value) end |