Class: Tweeb::Search

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/tweeb_search.rb

Constant Summary collapse

@@masher =
lambda {|hash| Mash.new(hash) }

Instance Method Summary collapse

Instance Method Details



34
35
36
37
# File 'lib/tweeb_search.rb', line 34

def current_trends
  json = self.class.get("/trends/current.json")
  @@masher.call(json)
end


39
40
41
42
# File 'lib/tweeb_search.rb', line 39

def daily_trends
  json = self.class.get("/trends/daily.json")
  @@masher.call(json)
end

#search(query, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tweeb_search.rb', line 14

def search(query, options={})
  if options.empty?
    json = self.class.get("/search.json", :query => {:q => query})
  else
    if options[:rpp] && options[:rpp] > 100
      raise Tweeb::SearchError, "rpp parameter must be < 100"
    end
    if options[:rpp] && options[:page] && (options[:rpp] * options[:page]) > 1500
      raise Tweeb::SearchError, "A maximum of 1500 tweets can be returned. Either lower rpp, or lower page options."
    end
    json = self.class.get("/search.json", :query => {:q => query}.merge(options))
  end
  @@masher.call(json)
end


29
30
31
32
# File 'lib/tweeb_search.rb', line 29

def trends
  json = self.class.get("/trends.json")
  @@masher.call(json)
end


44
45
46
47
# File 'lib/tweeb_search.rb', line 44

def weekly_trends
  json = self.class.get("/trends/weekly.json")
  @@masher.call(json)
end