class BackpackTF::UserListing

Constants

INTERFACE

Attributes

bump[R]
buyout[R]
created[R]
currencies[R]
details[R]
id[R]
item[R]
meta[R]

Public Class Methods

interface() click to toggle source
# File lib/backpack_tf/user_listing.rb, line 10
def self.interface; @interface; end
listings() click to toggle source
# File lib/backpack_tf/user_listing.rb, line 16
def self.listings
  return @response if response.nil?
  @@listings = response[:listings].inject([]) do |listings, attr|
    listings << new(attr)
    listings
  end
end
new(attr) click to toggle source
# File lib/backpack_tf/user_listing.rb, line 33
def initialize attr
  attr = check_attr_keys(attr)

  @id = attr[:id].to_sym
  @bump = attr[:bump]
  @created = attr[:created]
  @currencies = attr[:currencies]
  @item = set_keys_of_key_to_symbols(attr[:item], 'attributes')
  @details = attr[:details]
  @meta = self.class.hash_keys_to_sym(attr[:meta])
  @buyout = attr[:buyout]
end
response() click to toggle source
# File lib/backpack_tf/user_listing.rb, line 12
def self.response
  @response = superclass.responses[to_sym]
end

Private Instance Methods

set_keys_of_key_to_symbols(attr, key) click to toggle source

Similar to Response.hash_key_to_sym, except you are returning an Array of Hash objects instead of a Hash.

# File lib/backpack_tf/user_listing.rb, line 49
def set_keys_of_key_to_symbols attr, key
  return nil unless attr.has_key? key

  item_attributes = attr[key].map do |set_of_attr|
    self.class.hash_keys_to_sym(set_of_attr)
  end
  attr[key] = item_attributes

  self.class.hash_keys_to_sym(attr)
end