Sha256: fad8f4d6ff2427582940f24647a39e739e19283bee410bca794eb87007e0829f

Contents?: true

Size: 965 Bytes

Versions: 12

Compression:

Stored size: 965 Bytes

Contents

module Bitstamp
  class Collection
    attr_accessor :access_token, :module, :name, :model, :path

    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

    def all(options = {})
      Bitstamp::Helper.parse_objects! Bitstamp::Net::get(self.path).body_str, self.model
    end

    def create(options = {})
      Bitstamp::Helper.parse_object! Bitstamp::Net::post(self.path, options).body_str, self.model
    end

    def find(id, options = {})
      Bitstamp::Helper.parse_object! Bitstamp::Net::get("#{self.path}/#{id}").body_str, self.model
    end

    def update(id, options = {})
      Bitstamp::Helper.parse_object! Bitstamp::Net::patch("#{self.path}/#{id}", options).body_str, self.model
    end
  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
bitstamp-rbtc-arbitrage-0.4.0 lib/bitstamp/collection.rb
rbtc_arbitrage-2.3.0 bitstamp/lib/bitstamp/collection.rb
rbtc_arbitrage-2.2.1 bitstamp/lib/bitstamp/collection.rb
rbtc_arbitrage-2.2.0 bitstamp/lib/bitstamp/collection.rb
rbtc_arbitrage-2.1.2 bitstamp/lib/bitstamp/collection.rb
rbtc_arbitrage-2.1.1 bitstamp/lib/bitstamp/collection.rb
rbtc_arbitrage-2.1.0 bitstamp/lib/bitstamp/collection.rb
cgore-bitstamp-0.3.1 lib/bitstamp/collection.rb
bitstamp-0.3.0 lib/bitstamp/collection.rb
bitstamp-0.2.8 lib/bitstamp/collection.rb
bitstamp-0.2.7 lib/bitstamp/collection.rb
bitstamp-0.2.6 lib/bitstamp/collection.rb