Class: OmniScrapper::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/omni_scrapper/configuration.rb

Constant Summary collapse

SINGLE_OPTS =
%i[ do method ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
12
# File 'lib/omni_scrapper/configuration.rb', line 9

def initialize
  @fields = {}
  @anchors = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/omni_scrapper/configuration.rb', line 21

def method_missing(method_name, *args, &block)
  if args.empty?
    get_variable(method_name)
  else
    set_variable(method_name, args)
  end
end

Instance Attribute Details

#anchorsObject (readonly)

Returns the value of attribute anchors.



5
6
7
# File 'lib/omni_scrapper/configuration.rb', line 5

def anchors
  @anchors
end

#fieldsObject (readonly)

Returns the value of attribute fields.



5
6
7
# File 'lib/omni_scrapper/configuration.rb', line 5

def fields
  @fields
end

Instance Method Details

#field(name, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/omni_scrapper/configuration.rb', line 14

def field(name, options = {})
  #validate_crawler_presence!(options)
  validate_field_options!(options)
  # TODO: validate if field method is defined
  @fields[name] = options
end