Sha256: 61ca45be3258597969ba9becd7c3619f82934f92a334ff536cbbf504dd4d242e

Contents?: true

Size: 989 Bytes

Versions: 1

Compression:

Stored size: 989 Bytes

Contents

module Devrant
  class Rants
    include HTTParty
    include Devrant    

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

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

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

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

    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

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

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devrant-0.9.0 lib/devrant/rants.rb