Class: Devrant::Rants

Inherits:
Object
  • Object
show all
Includes:
Devrant, HTTParty
Defined in:
lib/devrant/rants.rb

Constant Summary

Constants included from Devrant

VERSION

Instance Method Summary collapse

Methods included from Devrant

#extend_request_query, #structuralize

Instance Method Details

#allObject



6
7
8
# File 'lib/devrant/rants.rb', line 6

def all
  structuralize(self.class.get('/devrant/rants')).rants
end

#collabsObject



22
23
24
# File 'lib/devrant/rants.rb', line 22

def collabs
  structuralize(self.class.get('/devrant/collabs')).rants
end

#get_rant(id) ⇒ Object

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
# File 'lib/devrant/rants.rb', line 26

def get_rant(id)
  rant = structuralize(self.class.get("/devrant/rants/#{id}")).rant

  return rant unless rant.nil?

  raise ArgumentError.new("No rant found for id #{id}")
end

#get_rants(params = {}) ⇒ Object



34
35
36
# File 'lib/devrant/rants.rb', line 34

def get_rants(params={})
  structuralize(self.class.get('/devrant/rants', extend_request_query(params))).rants 
end

#randomObject



14
15
16
# File 'lib/devrant/rants.rb', line 14

def random
  structuralize(self.class.get('/devrant/rants/surprise')).rant
end

#search(term) ⇒ Object



38
39
40
# File 'lib/devrant/rants.rb', line 38

def search(term)
  structuralize(self.class.get('/devrant/search', extend_request_query({term: term}))).results
end

#storiesObject



18
19
20
# File 'lib/devrant/rants.rb', line 18

def stories
  structuralize(self.class.get('/devrant/story-rants')).rants
end

#weeklyObject



10
11
12
# File 'lib/devrant/rants.rb', line 10

def weekly
  structuralize(self.class.get('/devrant/weekly-rants')).rants
end