Class: Crabfarm::BaseReducer
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#examine, included
#attributes=, #field_hash, included, #mock, #reset_fields
#assert
Methods included from Base
#debugger
Constructor Details
#initialize(_target, _params) ⇒ BaseReducer
Returns a new instance of BaseReducer.
30
31
32
33
34
35
36
37
38
|
# File 'lib/crabfarm/base_reducer.rb', line 30
def initialize(_target, _params)
reset_fields
@raw_document = parser.preprocess_parsing_target _target
@document = parser.parse @raw_document
@params = _params
super @document
end
|
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
11
12
13
|
# File 'lib/crabfarm/base_reducer.rb', line 11
def document
@document
end
|
#params ⇒ Object
Returns the value of attribute params.
11
12
13
|
# File 'lib/crabfarm/base_reducer.rb', line 11
def params
@params
end
|
#raw_document ⇒ Object
Returns the value of attribute raw_document.
11
12
13
|
# File 'lib/crabfarm/base_reducer.rb', line 11
def raw_document
@raw_document
end
|
Class Method Details
.parser ⇒ Object
17
18
19
|
# File 'lib/crabfarm/base_reducer.rb', line 17
def self.parser
@parser ||= Strategies.load(:parser, @parser_name || Crabfarm.config.parser)
end
|
.snapshot_path(_name = nil) ⇒ Object
21
22
23
24
|
# File 'lib/crabfarm/base_reducer.rb', line 21
def self.snapshot_path(_name=nil)
_name = self.to_s.underscore if _name.nil?
Utils::Resolve.snapshot_path _name, parser.format
end
|
.use_parser(_parser_name) ⇒ Object
13
14
15
|
# File 'lib/crabfarm/base_reducer.rb', line 13
def self.use_parser(_parser_name)
@parser_name = _parser_name
end
|
Instance Method Details
#__getobj__ ⇒ Object
48
49
50
|
# File 'lib/crabfarm/base_reducer.rb', line 48
def __getobj__
@document
end
|
#__setobj__(obj) ⇒ Object
52
53
54
|
# File 'lib/crabfarm/base_reducer.rb', line 52
def __setobj__(obj)
@document = obj
end
|
#parser ⇒ Object
26
27
28
|
# File 'lib/crabfarm/base_reducer.rb', line 26
def parser
self.class.parser
end
|
#run ⇒ Object
40
41
42
|
# File 'lib/crabfarm/base_reducer.rb', line 40
def run
raise NotImplementedError.new
end
|
#to_json(_options = nil) ⇒ Object
44
45
46
|
# File 'lib/crabfarm/base_reducer.rb', line 44
def to_json(_options=nil)
field_hash.to_json _options
end
|