Class: AutoPilot::DocumentParser
- Inherits:
-
Object
- Object
- AutoPilot::DocumentParser
- Defined in:
- lib/auto_pilot/document_parser.rb
Instance Attribute Summary collapse
-
#answer_id ⇒ Object
readonly
Returns the value of attribute answer_id.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#question_id ⇒ Object
readonly
Returns the value of attribute question_id.
Instance Method Summary collapse
- #answer_html ⇒ Object
- #answer_text ⇒ Object
-
#initialize(doc, question_id, answer_id) ⇒ DocumentParser
constructor
A new instance of DocumentParser.
- #question_html ⇒ Object
- #question_text ⇒ Object
- #title_html ⇒ Object
- #title_text ⇒ Object
Constructor Details
#initialize(doc, question_id, answer_id) ⇒ DocumentParser
Returns a new instance of DocumentParser.
5 6 7 8 9 |
# File 'lib/auto_pilot/document_parser.rb', line 5 def initialize(doc, question_id, answer_id) @doc = Nokogiri::HTML(doc) @question_id = question_id @answer_id = answer_id end |
Instance Attribute Details
#answer_id ⇒ Object (readonly)
Returns the value of attribute answer_id.
4 5 6 |
# File 'lib/auto_pilot/document_parser.rb', line 4 def answer_id @answer_id end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
4 5 6 |
# File 'lib/auto_pilot/document_parser.rb', line 4 def doc @doc end |
#question_id ⇒ Object (readonly)
Returns the value of attribute question_id.
4 5 6 |
# File 'lib/auto_pilot/document_parser.rb', line 4 def question_id @question_id end |
Instance Method Details
#answer_html ⇒ Object
27 28 29 |
# File 'lib/auto_pilot/document_parser.rb', line 27 def answer_html doc.css(xml_map[:answer]).inner_html end |
#answer_text ⇒ Object
31 32 33 |
# File 'lib/auto_pilot/document_parser.rb', line 31 def answer_text doc.css(xml_map[:answer]).text end |
#question_html ⇒ Object
19 20 21 |
# File 'lib/auto_pilot/document_parser.rb', line 19 def question_html doc.css(xml_map[:question]).inner_html end |
#question_text ⇒ Object
23 24 25 |
# File 'lib/auto_pilot/document_parser.rb', line 23 def question_text doc.css(xml_map[:question]).text # you can also call inner_html for semantic formatting end |
#title_html ⇒ Object
11 12 13 |
# File 'lib/auto_pilot/document_parser.rb', line 11 def title_html doc.css(xml_map[:h1]).inner_html end |
#title_text ⇒ Object
15 16 17 |
# File 'lib/auto_pilot/document_parser.rb', line 15 def title_text doc.css(xml_map[:h1]).text end |