Class: Scraptacular::Result
- Inherits:
-
Object
- Object
- Scraptacular::Result
show all
- Defined in:
- lib/scraptacular/result.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(page) ⇒ Result
Returns a new instance of Result.
5
6
7
8
|
# File 'lib/scraptacular/result.rb', line 5
def initialize(page)
@page = page
@result = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
18
19
20
21
|
# File 'lib/scraptacular/result.rb', line 18
def method_missing(method_name, *args, &block)
@result[method_name] = instance_eval(&block)
end
|
Instance Attribute Details
#page ⇒ Object
Returns the value of attribute page.
3
4
5
|
# File 'lib/scraptacular/result.rb', line 3
def page
@page
end
|
Instance Method Details
#merge(other_result, priority = :other) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/scraptacular/result.rb', line 10
def merge(other_result, priority = :other)
if priority == :other
@result.merge! other_result.to_h
else
@result = other_result.to_h.merge @result
end
end
|
#to_h ⇒ Object
23
24
25
|
# File 'lib/scraptacular/result.rb', line 23
def to_h
@result
end
|
#to_json ⇒ Object
27
28
29
|
# File 'lib/scraptacular/result.rb', line 27
def to_json
@result.to_json
end
|