Class: SteamCondenser::Community::TF2GoldenWrench

Inherits:
Object
  • Object
show all
Defined in:
lib/steam-condenser/community/tf2/tf2_golden_wrench.rb

Overview

Represents the special Team Fortress 2 item Golden Wrench. It includes the ID of the item, the serial number of the wrench, a reference to the SteamID of the owner and the date this player crafted the wrench

Author:

  • Sebastian Staudt

Constant Summary collapse

@@golden_wrenches =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrench_data) ⇒ TF2GoldenWrench (private)

Creates a new instance of a Golden Wrench with the given data

Parameters:

  • wrench_data (Hash<Symbol, Object>)

    The JSON data for this wrench


65
66
67
68
69
70
# File 'lib/steam-condenser/community/tf2/tf2_golden_wrench.rb', line 65

def initialize(wrench_data)
  @date   = Time.at(wrench_data[:timestamp])
  @id     = wrench_data[:itemID]
  @number = wrench_data[:wrenchNumber]
  @owner  = SteamId.new(wrench_data[:steamID], false)
end

Instance Attribute Details

#dateTime (readonly)

Returns the date this Golden Wrench has been crafted

Returns:

  • (Time)

    The crafting date of this wrench


23
24
25
# File 'lib/steam-condenser/community/tf2/tf2_golden_wrench.rb', line 23

def date
  @date
end

#idFixnum (readonly)

Returns the unique item ID of this Golden Wrench

Returns:

  • (Fixnum)

    The ID of this wrench


28
29
30
# File 'lib/steam-condenser/community/tf2/tf2_golden_wrench.rb', line 28

def id
  @id
end

#numberFixnum (readonly)

Returns the serial number of this Golden Wrench

Returns:

  • (Fixnum)

    The serial of this wrench


33
34
35
# File 'lib/steam-condenser/community/tf2/tf2_golden_wrench.rb', line 33

def number
  @number
end

#ownerSteamId (readonly)

Returns the SteamID of the owner of this Golden Wrench

Returns:

  • (SteamId)

    The owner of this wrench


38
39
40
# File 'lib/steam-condenser/community/tf2/tf2_golden_wrench.rb', line 38

def owner
  @owner
end

Class Method Details

.golden_wrenchesArray<GoldenWrench>

Returns all Golden Wrenches

Returns:

  • (Array<GoldenWrench>)

    All Golden Wrenches

Raises:

  • (Error)

    if an error occurs querying the Web API or the Steam Community


47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/steam-condenser/community/tf2/tf2_golden_wrench.rb', line 47

def self.golden_wrenches
  if @@golden_wrenches.nil?
    @@golden_wrenches = []

    data = WebApi.json 'ITFItems_440', 'GetGoldenWrenches', 2
    data[:results][:wrenches].each do |wrench_data|
      @@golden_wrenches << TF2GoldenWrench.new(wrench_data)
    end
  end

  @@golden_wrenches
end