Class: JohnStamos::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/john_stamos/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
# File 'lib/john_stamos/client.rb', line 6

def initialize(options={})
  default_options = { proxy: nil }
  options = default_options.merge(options)
  @proxy = options[:proxy]
end

Instance Attribute Details

#proxyObject

Returns the value of attribute proxy.



4
5
6
# File 'lib/john_stamos/client.rb', line 4

def proxy
  @proxy
end

Instance Method Details

#json_content(url, params) ⇒ Object



33
34
35
36
37
# File 'lib/john_stamos/client.rb', line 33

def json_content(url, params)
  response = make_json_request(url, params)

  JSON.parse(response)
end

#page_content(url) ⇒ Object



27
28
29
30
31
# File 'lib/john_stamos/client.rb', line 27

def page_content(url)
  response = make_request(url)

  Nokogiri::HTML(response)
end

#pin(pinterest_pin_id) ⇒ Object



19
20
21
# File 'lib/john_stamos/client.rb', line 19

def pin(pinterest_pin_id)
  JohnStamos::Pin.new(self, pinterest_pin_id)
end

#pinner(username) ⇒ Object



23
24
25
# File 'lib/john_stamos/client.rb', line 23

def pinner(username)
  JohnStamos::Pinner.new(self, username)
end

#search_pins(search_text, options = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/john_stamos/client.rb', line 12

def search_pins(search_text, options={})
  search_scraper = JohnStamos::PinSearch.new(self, search_text, options)
  search_scraper.execute!

  search_scraper.pins
end