Class: Scrubyt::CompoundExample

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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_hashObject

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

Returns:

  • (Boolean)


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