Class: Gfycat::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/gfycat/client.rb', line 5

def initialize(options = {})
  @client = JsonClient.new(api_url, **options)
end

Instance Method Details

#exists?(url) ⇒ Boolean

Returns:

  • (Boolean)


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

def exists?(url)
  response = @client.get("checkUrl/#{CGI::escape(url)}")
  !!response["url_known"]
end

#get(name) ⇒ Object



14
15
16
17
# File 'lib/gfycat/client.rb', line 14

def get(name)
  response = @client.get("get/#{name}")
  Resources::Item.new(response["gfy_item"])
end

#transcode!(source) ⇒ Object



9
10
11
12
# File 'lib/gfycat/client.rb', line 9

def transcode!(source)
  response = @client.get(transcode_url, fetchUrl: source)
  response["gfy_name"]
end