class Bitstamp::Collection

Attributes

access_token[RW]
model[RW]
module[RW]
name[RW]
path[RW]

Public Class Methods

new(api_prefix="/api") click to toggle source
# File lib/bitstamp/collection.rb, line 5
def initialize(api_prefix="/api")
  self.access_token = Bitstamp.key

  self.module = self.class.to_s.singularize.underscore
  self.name   = self.module.split('/').last
  self.model  = self.module.camelize.constantize
  self.path   = "#{api_prefix}/#{self.name.pluralize}"
end

Public Instance Methods

all(options = {}) click to toggle source
# File lib/bitstamp/collection.rb, line 14
def all(options = {})
  Bitstamp::Helper.parse_objects! Bitstamp::Net.get(self.path).body, self.model
end
create(options = {}) click to toggle source
# File lib/bitstamp/collection.rb, line 18
def create(options = {})
  Bitstamp::Helper.parse_object! Bitstamp::Net.post(self.path, options).body, self.model
end
find(id, options = {}) click to toggle source
# File lib/bitstamp/collection.rb, line 22
def find(id, options = {})
  Bitstamp::Helper.parse_object! Bitstamp::Net.get("#{self.path}/#{id}").body, self.model
end
update(id, options = {}) click to toggle source
# File lib/bitstamp/collection.rb, line 26
def update(id, options = {})
  Bitstamp::Helper.parse_object! Bitstamp::Net.patch("#{self.path}/#{id}", options).body, self.model
end