Class: Vore::Handlers::MetaExtractor
- Inherits:
-
Object
- Object
- Vore::Handlers::MetaExtractor
- Defined in:
- lib/vore/handlers/meta_extractor.rb
Constant Summary collapse
- SELECTOR =
Selma::Selector.new(match_element: "*", match_text_within: "title")
Instance Attribute Summary collapse
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #handle_element(element) ⇒ Object
- #handle_text_chunk(text) ⇒ Object
-
#initialize ⇒ MetaExtractor
constructor
A new instance of MetaExtractor.
- #selector ⇒ Object
Constructor Details
#initialize ⇒ MetaExtractor
Returns a new instance of MetaExtractor.
10 11 12 13 14 15 |
# File 'lib/vore/handlers/meta_extractor.rb', line 10 def initialize super @title = "" @meta = {} @within_title = false end |
Instance Attribute Details
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
8 9 10 |
# File 'lib/vore/handlers/meta_extractor.rb', line 8 def @meta end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/vore/handlers/meta_extractor.rb', line 8 def title @title end |
Instance Method Details
#handle_element(element) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vore/handlers/meta_extractor.rb', line 21 def handle_element(element) if element.tag_name == "title" @within_title = true element.remove elsif element.tag_name == "meta" return if element.attributes["name"].nil? @meta[element.attributes["name"]] = element.attributes["content"] end end |
#handle_text_chunk(text) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/vore/handlers/meta_extractor.rb', line 33 def handle_text_chunk(text) if @within_title @within_title = false @title = text.to_s end end |
#selector ⇒ Object
17 18 19 |
# File 'lib/vore/handlers/meta_extractor.rb', line 17 def selector SELECTOR end |