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.



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

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.



2
3
4
# File 'lib/john_stamos/client.rb', line 2

def proxy
  @proxy
end

Instance Method Details

#json_content(url, params) ⇒ Object



31
32
33
34
35
# File 'lib/john_stamos/client.rb', line 31

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

  JSON.parse(response)
end

#page_content(url) ⇒ Object



25
26
27
28
29
# File 'lib/john_stamos/client.rb', line 25

def page_content(url)
  response = make_request(url)

  Nokogiri::HTML(response)
end

#pin(pinterest_pin_id) ⇒ Object



17
18
19
# File 'lib/john_stamos/client.rb', line 17

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

#pinner(username) ⇒ Object



21
22
23
# File 'lib/john_stamos/client.rb', line 21

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

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



10
11
12
13
14
15
# File 'lib/john_stamos/client.rb', line 10

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

  search_scraper.pins
end