Class: Bitstamp::Collection
- Inherits:
-
Object
- Object
- Bitstamp::Collection
- Defined in:
- lib/bitstamp/collection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#model ⇒ Object
Returns the value of attribute model.
-
#module ⇒ Object
Returns the value of attribute module.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #all(options = {}) ⇒ Object
- #create(options = {}) ⇒ Object
- #find(id, options = {}) ⇒ Object
-
#initialize(api_prefix = "/api") ⇒ Collection
constructor
A new instance of Collection.
- #update(id, options = {}) ⇒ Object
Constructor Details
#initialize(api_prefix = "/api") ⇒ Collection
Returns a new instance of Collection.
5 6 7 8 9 10 11 12 |
# 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 |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
3 4 5 |
# File 'lib/bitstamp/collection.rb', line 3 def access_token @access_token end |
#model ⇒ Object
Returns the value of attribute model.
3 4 5 |
# File 'lib/bitstamp/collection.rb', line 3 def model @model end |
#module ⇒ Object
Returns the value of attribute module.
3 4 5 |
# File 'lib/bitstamp/collection.rb', line 3 def module @module end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bitstamp/collection.rb', line 3 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/bitstamp/collection.rb', line 3 def path @path end |
Instance Method Details
#all(options = {}) ⇒ Object
14 15 16 |
# File 'lib/bitstamp/collection.rb', line 14 def all( = {}) Bitstamp::Helper.parse_objects! Bitstamp::Net::get(self.path).body_str, self.model end |
#create(options = {}) ⇒ Object
18 19 20 |
# File 'lib/bitstamp/collection.rb', line 18 def create( = {}) Bitstamp::Helper.parse_object! Bitstamp::Net::post(self.path, ).body_str, self.model end |