Class: Bitcoin::Currency

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin/currency.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cryptoObject

Returns the value of attribute crypto.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def crypto
  @crypto
end

#delistedObject

Returns the value of attribute delisted.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def delisted
  @delisted
end

#fullNameObject

Returns the value of attribute fullName.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def fullName
  @fullName
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def id
  @id
end

#payinConfirmationsObject

Returns the value of attribute payinConfirmations.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def payinConfirmations
  @payinConfirmations
end

#payinEnabledObject

Returns the value of attribute payinEnabled.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def payinEnabled
  @payinEnabled
end

#payinPaymentIdObject

Returns the value of attribute payinPaymentId.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def payinPaymentId
  @payinPaymentId
end

#payoutEnabledObject

Returns the value of attribute payoutEnabled.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def payoutEnabled
  @payoutEnabled
end

#payoutFeeObject

Returns the value of attribute payoutFee.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def payoutFee
  @payoutFee
end

#payoutIsPaymentIdObject

Returns the value of attribute payoutIsPaymentId.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def payoutIsPaymentId
  @payoutIsPaymentId
end

#transferEnabledObject

Returns the value of attribute transferEnabled.



3
4
5
# File 'lib/bitcoin/currency.rb', line 3

def transferEnabled
  @transferEnabled
end

Class Method Details

.allObject



7
8
9
10
11
12
# File 'lib/bitcoin/currency.rb', line 7

def self.all
  data = JSON.parse(RestClient.get("#{Bitcoin::BASE}/public/currency"))
  data.map{  |currency|
    Bitcoin::Currency.new_from_object(currency)
   }
end

.new_from_currency_name(name) ⇒ Object



14
15
16
17
# File 'lib/bitcoin/currency.rb', line 14

def self.new_from_currency_name(name)
  data = JSON.parse(RestClient.get("#{Bitcoin::BASE}/public/currency/#{name}"))
  Bitcoin::Currency.new_from_object(data)
end

.new_from_object(data) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/bitcoin/currency.rb', line 19

def self.new_from_object(data)
  c = Bitcoin::Currency.new
  c.id = data['id']
  c.fullName = data['fullName']
  c.crypto = data['crypto']
  c.payoutFee = data['payoutFee']
  c.payoutFee = c.payoutFee.to_f / 100 if c.id == 'USD'
  c
end

Instance Method Details

#display_detailsObject



29
30
31
32
33
34
35
36
37
# File 'lib/bitcoin/currency.rb', line 29

def display_details
  puts <<-DOC
    #{@id} (#{@fullName})
    Cryptocurrency?: #{@crypto.to_s}
    Delisted?: #{@delisted.to_s}
    Pay-Out Fee: #{@payoutFee} #{@id}

  DOC
end