Class: Trendious::Client

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

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



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

def initialize
end

Instance Method Details

#posts_by_name(name, page = 0) ⇒ Object



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

def posts_by_name(name, page = 0)
  form_name = name.gsub!(' ', '%20')
  search({q: name, without_type: "user,tag", page: page})
end

#search(hash = {}) ⇒ Object



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

def search(hash = {})
  query = {q: "marvel"}.merge!(hash)
  query = query.map {|k,v| "#{k}=#{v}" }.join("&")
  uri = URI("http://api.moviepilot.com/v3/search?#{query}")
  puts "Request URI: #{uri}"
  Trendious::Search.new Net::HTTP.get(uri)
end

#tagsObject



18
19
20
# File 'lib/trendious/client.rb', line 18

def tags
  Trendious::Tags.new Net::HTTP.get(URI('http://api.moviepilot.com/v4/tags'))
end

#tags_by_name(name, page = 0) ⇒ Object



27
28
29
# File 'lib/trendious/client.rb', line 27

def tags_by_name(name, page = 0)
  search({q: name, with_type: "tag", page: page})
end