Class: Roe::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, format = :json) ⇒ Client

Returns a new instance of Client.



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

def initialize(endpoint, format = :json)
  @endpoint = endpoint
  @format = format

  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", Roe.options[key])
  end
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



6
7
8
# File 'lib/roe/client.rb', line 6

def endpoint
  @endpoint
end

#formatObject

Returns the value of attribute format.



6
7
8
# File 'lib/roe/client.rb', line 6

def format
  @format
end

Instance Method Details

#resolve(uri, options = {}) ⇒ Object



18
19
20
21
22
23
# File 'lib/roe/client.rb', line 18

def resolve(uri, options={})
  response = connection.get do |req|
    req.url endpoint_path, options.merge!(:url => uri, :format => format)
  end
  response.body.oembed || response.body
end