class BitShares::Asset

Attributes

id[R]
name[R]

Public Class Methods

[](*ids) click to toggle source
# File lib/bitshares/asset.rb, line 17
def [] *ids
        id = ids.first
        if /^\d\.\d*\.\d*/.match(id)
                unless hash.key? id
                        arr = RPC.new('get_assets',[[id]]).send.inject([]) {|m,a| m << Asset.new(a) }
                end
                (ids.size == 1) ? (hash[ida]) : (arr) 
        else
                arr = []
                hash.each_pair do |k,v|
                        if ids.include? v.name
                                (ids.size == 1) ? (return v) : (arr << v)
                        end
                end
                arr
        end
end
add(h) click to toggle source
# File lib/bitshares/asset.rb, line 39
def add h
        hash[h.id] = h unless hash.key? h.id
end
hash() click to toggle source
# File lib/bitshares/asset.rb, line 43
def hash() @h ||= {} end
new(hash) click to toggle source
# File lib/bitshares/asset.rb, line 5
def initialize hash
        @id = hash['id']
        @name = hash['symbol']
        @hash = hash
        self.class.add self
end

Public Instance Methods

to_s() click to toggle source
# File lib/bitshares/asset.rb, line 12
def to_s
        @name
end