Class: Scrubyt::CompoundExample
- Inherits:
-
Object
- Object
- Scrubyt::CompoundExample
- Defined in:
- lib/scrubyt/core/scraping/compound_example.rb
Overview
Represents a compund example
There are two types of string examples in scRUBYt! right now: the simple example and the compound example. The simple example is specified by a string, and a compound example is specified with :contains, :begins_with and :ends_with descriptors - which can be both regexps or strings
Constant Summary collapse
- DESCRIPTORS =
[:contains, :begins_with, :ends_with]
Instance Attribute Summary collapse
-
#descriptor_hash ⇒ Object
Returns the value of attribute descriptor_hash.
Class Method Summary collapse
-
.compound_example?(hash) ⇒ Boolean
Is the hash passed to this function a compound example descriptor hash? Need to decide this when parsing pattern parameters.
Instance Method Summary collapse
-
#initialize(descriptor_hash) ⇒ CompoundExample
constructor
A new instance of CompoundExample.
Constructor Details
#initialize(descriptor_hash) ⇒ CompoundExample
Returns a new instance of CompoundExample.
16 17 18 |
# File 'lib/scrubyt/core/scraping/compound_example.rb', line 16 def initialize(descriptor_hash) @descriptor_hash = descriptor_hash end |
Instance Attribute Details
#descriptor_hash ⇒ Object
Returns the value of attribute descriptor_hash.
14 15 16 |
# File 'lib/scrubyt/core/scraping/compound_example.rb', line 14 def descriptor_hash @descriptor_hash end |
Class Method Details
.compound_example?(hash) ⇒ Boolean
Is the hash passed to this function a compound example descriptor hash? Need to decide this when parsing pattern parameters
23 24 25 26 27 28 |
# File 'lib/scrubyt/core/scraping/compound_example.rb', line 23 def self.compound_example?(hash) hash.each do |k,v| return false if !DESCRIPTORS.include? k end true end |