Class: Bitstamp::Model

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Model, ActiveModel::Validations
Defined in:
lib/bitstamp/model.rb

Direct Known Subclasses

Order, Ticker, Transactions, UserTransaction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Model

Returns a new instance of Model.



10
11
12
# File 'lib/bitstamp/model.rb', line 10

def initialize(attributes = {})
  self.attributes = attributes
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/bitstamp/model.rb', line 3

def error
  @error
end

#messageObject

Returns the value of attribute message.



3
4
5
# File 'lib/bitstamp/model.rb', line 3

def message
  @message
end

Instance Method Details

#attributesObject

Returns a hash with the current instance variables



29
30
31
# File 'lib/bitstamp/model.rb', line 29

def attributes
  Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]
end

#attributes=(attributes = {}) ⇒ Object

Set the attributes based on the given hash



18
19
20
21
22
23
24
25
26
# File 'lib/bitstamp/model.rb', line 18

def attributes=(attributes = {})
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    rescue NoMethodError => e
      puts "Unable to assign #{name}. No such method."
    end
  end
end