Class: BitShares::Asset
- Inherits:
-
Object
- Object
- BitShares::Asset
- Defined in:
- lib/bitshares/asset.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ Asset
constructor
A new instance of Asset.
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ Asset
Returns a new instance of Asset.
5 6 7 8 9 10 |
# File 'lib/bitshares/asset.rb', line 5 def initialize hash @id = hash['id'] @name = hash['symbol'] @hash = hash self.class.add self end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/bitshares/asset.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/bitshares/asset.rb', line 3 def name @name end |
Class Method Details
.[](id) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bitshares/asset.rb', line 17 def [] id if /^\d\.\d*\.\d*/.match(id) BitShares.assets id unless hash.key? id hash[id] else hash.each_pair do |k,v| return v if v.name == id end end end |
.add(h) ⇒ Object
28 29 30 |
# File 'lib/bitshares/asset.rb', line 28 def add h hash[h.id] = h unless hash.key? h.id end |
.hash ⇒ Object
32 |
# File 'lib/bitshares/asset.rb', line 32 def hash() @h ||= {} end |
Instance Method Details
#to_s ⇒ Object
12 13 14 |
# File 'lib/bitshares/asset.rb', line 12 def to_s @name end |