Module: Biostars::API

Defined in:
lib/biostars/api.rb,
lib/biostars/api/post.rb,
lib/biostars/api/user.rb,
lib/biostars/api/vote.rb,
lib/biostars/api/stats.rb,
lib/biostars/api/traffic.rb,
lib/biostars/api/version.rb

Defined Under Namespace

Classes: Post, Stats, Traffic, User, Vote

Constant Summary collapse

API_URL =

Used for API requests

'https://www.biostars.org/api'
VERSION =

Biostars::API Version

"0.1.1"

Class Method Summary collapse

Class Method Details

.get(url) ⇒ Hash

Used for general GET http requests to the API



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

def self.get(url)
  response = HTTParty.get "#{API_URL}/#{url}"
  response.success? ? JSON.parse(response.body) : false
end

.trafficTraffic

Number of post views over the last 60 min filtered by unique IPs.

Raises:



25
26
27
28
# File 'lib/biostars/api.rb', line 25

def self.traffic
	attributes = Biostars::API.get "traffic"
   attributes ? Biostars::API::Traffic.new(attributes) : raise(Biostars::Error)
end