Module: LCBO::CrawlKit::Page::ClassMethods

Defined in:
lib/lcbo/crawlkit/page.rb

Instance Method Summary collapse

Instance Method Details

#default_body_params(value = nil) ⇒ Object


24
25
26
27
28
29
30
# File 'lib/lcbo/crawlkit/page.rb', line 24

def default_body_params(value = nil)
  if value
    @request_prototype.body_params = value
  else
    @request_prototype.body_params
  end
end

#emits(field, &block) ⇒ Object


40
41
42
43
# File 'lib/lcbo/crawlkit/page.rb', line 40

def emits(field, &block)
  fields << field.to_sym
  define_method(field) { instance_exec(field, &block) } if block_given?
end

#fieldsObject


57
58
59
# File 'lib/lcbo/crawlkit/page.rb', line 57

def fields
  @fields
end

#http_method(value = nil) ⇒ Object


32
33
34
35
36
37
38
# File 'lib/lcbo/crawlkit/page.rb', line 32

def http_method(value = nil)
  if value
    @request_prototype.http_method = value
  else
    @request_prototype.http_method
  end
end

#parse(response) ⇒ Object


49
50
51
# File 'lib/lcbo/crawlkit/page.rb', line 49

def parse(response)
  new(nil, nil, response).parse
end

#process(query_params = {}, body_params = {}) ⇒ Object


53
54
55
# File 'lib/lcbo/crawlkit/page.rb', line 53

def process(query_params = {}, body_params = {})
  new(query_params, body_params).process
end

#request(query_params = {}, body_params = {}) ⇒ Object


45
46
47
# File 'lib/lcbo/crawlkit/page.rb', line 45

def request(query_params = {}, body_params = {})
  new(query_params, body_params).request
end

#request_prototypeObject


61
62
63
# File 'lib/lcbo/crawlkit/page.rb', line 61

def request_prototype
  @request_prototype
end

#uri(value = nil) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/lcbo/crawlkit/page.rb', line 16

def uri(value = nil)
  if value
    @request_prototype.uri_template = value
  else
    @request_prototype.uri_template
  end
end