Class: MtGox::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mtgox/base.rb

Direct Known Subclasses

AskBase, Depth, Order, Ticker, Trade

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
10
11
# File 'lib/mtgox/base.rb', line 5

def initialize(attrs={})
  @attrs = attrs

  attrs.each {|k, v|
    send "#{k}=", v rescue NoMethodError
  }
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



3
4
5
# File 'lib/mtgox/base.rb', line 3

def attrs
  @attrs
end

Instance Method Details

#inspectObject

skip @attrs



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mtgox/base.rb', line 14

def inspect
  ret = "#<#{self.class}:0x#{object_id}"

  vars = instance_variables.each.with_object([]) do |n, memo|
    next if n == :@attrs
    memo << "#{n}=#{instance_variable_get(n).inspect}"
  end

  ret << " #{vars.join(", ")}" unless vars.empty?
  ret << ">"

  ret
end