Class: BackpackTF::Currency
- Defined in:
- lib/backpack_tf/currency.rb
Overview
ruby representations of a JSON response to
IGetCurrencies['response']
Constant Summary collapse
- INTERFACE =
Class Methods
:IGetCurrencies- @@currencies =
nil
Instance Attribute Summary collapse
-
#blanket ⇒ Fixnum
readonly
TODO: what does the :blanket attribute mean? it is set to 0 by default.
-
#craftable ⇒ Symbol
readonly
Either :Craftable or :Non-Craftable to signify currency's craftability.
-
#defindex ⇒ Fixnum
readonly
The definition index of the currency.
-
#plural ⇒ String
readonly
The plural form of noun that is used in the suffix.
-
#priceindex ⇒ Fixnum
readonly
The internal priceindex of the currency.
-
#quality ⇒ Fixnum
readonly
The quality index of the currency.
-
#round ⇒ Fixnum
readonly
The number of decimal places the price should be rounded to.
-
#single ⇒ String
readonly
The single form of noun that is used in the suffix.
-
#tradable ⇒ Symbol
readonly
Either :Tradable or :Non-Tradable to signify currency's tradability.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, attr) ⇒ Currency
constructor
A new instance of Currency.
Methods inherited from Response
hash_keys_to_sym, interface, responses, to_sym
Constructor Details
#initialize(name, attr) ⇒ Currency
Returns a new instance of Currency.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/backpack_tf/currency.rb', line 52 def initialize name, attr attr = check_attr_keys(attr) @name = name.to_s @quality = attr[:quality] @priceindex = attr[:priceindex] @single = attr[:single] @plural = attr[:plural] @round = attr[:round] @craftable = attr[:craftable].to_sym @tradable = attr[:tradable].to_sym @defindex = attr[:defindex] @blanket = attr[:blanket] end |
Instance Attribute Details
#blanket ⇒ Fixnum (readonly)
TODO: what does the :blanket attribute mean? it is set to 0 by default. However, it is set to 1 for :hat. :hat also has an extra property & value :blanket_name => 'Random Craft Hat'
50 51 52 |
# File 'lib/backpack_tf/currency.rb', line 50 def blanket @blanket end |
#craftable ⇒ Symbol (readonly)
Returns either :Craftable or :Non-Craftable to signify currency's craftability.
41 42 43 |
# File 'lib/backpack_tf/currency.rb', line 41 def craftable @craftable end |
#defindex ⇒ Fixnum (readonly)
Returns the definition index of the currency.
45 46 47 |
# File 'lib/backpack_tf/currency.rb', line 45 def defindex @defindex end |
#plural ⇒ String (readonly)
Returns the plural form of noun that is used in the suffix.
37 38 39 |
# File 'lib/backpack_tf/currency.rb', line 37 def plural @plural end |
#priceindex ⇒ Fixnum (readonly)
Returns the internal priceindex of the currency.
33 34 35 |
# File 'lib/backpack_tf/currency.rb', line 33 def priceindex @priceindex end |
#quality ⇒ Fixnum (readonly)
Returns the quality index of the currency.
31 32 33 |
# File 'lib/backpack_tf/currency.rb', line 31 def quality @quality end |
#round ⇒ Fixnum (readonly)
Returns the number of decimal places the price should be rounded to.
39 40 41 |
# File 'lib/backpack_tf/currency.rb', line 39 def round @round end |
#single ⇒ String (readonly)
Returns the single form of noun that is used in the suffix.
35 36 37 |
# File 'lib/backpack_tf/currency.rb', line 35 def single @single end |
#tradable ⇒ Symbol (readonly)
Returns either :Tradable or :Non-Tradable to signify currency's tradability.
43 44 45 |
# File 'lib/backpack_tf/currency.rb', line 43 def tradable @tradable end |
Class Method Details
.currencies ⇒ Object
20 21 22 23 24 |
# File 'lib/backpack_tf/currency.rb', line 20 def self.currencies return @response if @response.nil? @@currencies = response[:currencies] hash_keys_to_sym(@@currencies) end |
.response ⇒ Object
16 17 18 |
# File 'lib/backpack_tf/currency.rb', line 16 def self.response @response = superclass.responses[to_sym] end |