Class: Scrubyt::AttributeFilter
- Inherits:
-
BaseFilter
- Object
- BaseFilter
- Scrubyt::AttributeFilter
- Defined in:
- lib/scrubyt/core/scraping/filters/attribute_filter.rb
Constant Summary
Constants inherited from BaseFilter
BaseFilter::EXAMPLE_TYPE_CHILDREN, BaseFilter::EXAMPLE_TYPE_COMPOUND, BaseFilter::EXAMPLE_TYPE_IMAGE, BaseFilter::EXAMPLE_TYPE_REGEXP, BaseFilter::EXAMPLE_TYPE_STRING, BaseFilter::EXAMPLE_TYPE_XPATH
Instance Attribute Summary
Attributes inherited from BaseFilter
#constraints, #example, #example_type, #final_result, #parent_pattern, #regexp, #temp_sink, #xpath
Instance Method Summary collapse
Methods inherited from BaseFilter
create, #method_missing, #throw_method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Scrubyt::BaseFilter
Instance Method Details
#evaluate(source) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/scrubyt/core/scraping/filters/attribute_filter.rb', line 4 def evaluate(source) elem = XPathUtils.find_nearest_node_with_attribute(source, @example) if elem.is_a? Hpricot::Elem return [elem.attributes[@example]] else return nil end end |
#to_sexp ⇒ Object
13 14 15 |
# File 'lib/scrubyt/core/scraping/filters/attribute_filter.rb', line 13 def to_sexp [:str, @example] end |