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 Attribute Summary collapse

Instance Method Summary collapse

Methods included from Devrant

#extend_request, #structuralize

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



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

def parent
  @parent
end

Instance Method Details

#allObject



8
9
10
# File 'lib/devrant/rants.rb', line 8

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

#collabsObject



24
25
26
# File 'lib/devrant/rants.rb', line 24

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

#comment(rant, content, token_id, token_key, user_id) ⇒ Object



44
45
46
# File 'lib/devrant/rants.rb', line 44

def comment(rant, content, token_id, token_key, user_id)
  structuralize(self.class.post("/devrant/rants/#{rant}/comments", extend_request(:body, {token_id: token_id, token_key: token_key, user_id: user_id, comment: content})))
end

#get_rant(id) ⇒ Object

Raises:

  • (ArgumentError)


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

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



36
37
38
# File 'lib/devrant/rants.rb', line 36

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

#randomObject



16
17
18
# File 'lib/devrant/rants.rb', line 16

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

#search(term) ⇒ Object



40
41
42
# File 'lib/devrant/rants.rb', line 40

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

#storiesObject



20
21
22
# File 'lib/devrant/rants.rb', line 20

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

#weeklyObject



12
13
14
# File 'lib/devrant/rants.rb', line 12

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