Class: BackpackTF::Currencies

Inherits:
Response
  • Object
show all
Defined in:
lib/backpack_tf/currencies.rb

Overview

ruby representations of a JSON response to IGetCurrencies['response']

Constant Summary collapse

INTERFACE =

Class Methods

:IGetCurrencies
@@currencies =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Response

hash_keys_to_sym, interface, responses, to_sym

Constructor Details

#initialize(name, attr) ⇒ Currencies

Returns a new instance of Currencies.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/backpack_tf/currencies.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'

Returns:

  • (Fixnum)


50
51
52
# File 'lib/backpack_tf/currencies.rb', line 50

def blanket
  @blanket
end

#craftable ⇒ Symbol (readonly)

Returns either :Craftable or :Non-Craftable to signify currency's craftability.

Returns:

  • (Symbol) —

    either :Craftable or :Non-Craftable to signify currency's craftability



41
42
43
# File 'lib/backpack_tf/currencies.rb', line 41

def craftable
  @craftable
end

#defindex ⇒ Fixnum (readonly)

Returns the definition index of the currency.

Returns:

  • (Fixnum) —

    the definition index of the currency



45
46
47
# File 'lib/backpack_tf/currencies.rb', line 45

def defindex
  @defindex
end

#plural ⇒ String (readonly)

Returns the plural form of noun that is used in the suffix.

Returns:

  • (String) —

    the plural form of noun that is used in the suffix



37
38
39
# File 'lib/backpack_tf/currencies.rb', line 37

def plural
  @plural
end

#priceindex ⇒ Fixnum (readonly)

Returns the internal priceindex of the currency.

Returns:

  • (Fixnum) —

    the internal priceindex of the currency



33
34
35
# File 'lib/backpack_tf/currencies.rb', line 33

def priceindex
  @priceindex
end

#quality ⇒ Fixnum (readonly)

Returns the quality index of the currency.

Returns:

  • (Fixnum) —

    the quality index of the currency



31
32
33
# File 'lib/backpack_tf/currencies.rb', line 31

def quality
  @quality
end

#round ⇒ Fixnum (readonly)

Returns the number of decimal places the price should be rounded to.

Returns:

  • (Fixnum) —

    the number of decimal places the price should be rounded to



39
40
41
# File 'lib/backpack_tf/currencies.rb', line 39

def round
  @round
end

#single ⇒ String (readonly)

Returns the single form of noun that is used in the suffix.

Returns:

  • (String) —

    the single form of noun that is used in the suffix



35
36
37
# File 'lib/backpack_tf/currencies.rb', line 35

def single
  @single
end

#tradable ⇒ Symbol (readonly)

Returns either :Tradable or :Non-Tradable to signify currency's tradability.

Returns:

  • (Symbol) —

    either :Tradable or :Non-Tradable to signify currency's tradability



43
44
45
# File 'lib/backpack_tf/currencies.rb', line 43

def tradable
  @tradable
end

Class Method Details

.currencies ⇒ Object



20
21
22
23
24
# File 'lib/backpack_tf/currencies.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/currencies.rb', line 16

def self.response
  @response = superclass.responses[to_sym]
end