Module: TF2ClassFactory

Defined in:
lib/steam/community/tf2/tf2_class_factory.rb

Overview

The ‘TF2ClassFactory` is used to created instances of `TF2Class` based on the XML input data

Author:

  • Sebastian Staudt

Class Method Summary collapse

Class Method Details

.tf2_class(class_data) ⇒ TF2Class

Creates a new instance of a TF2 class instance based on the given XML data

This returns an instance of ‘TF2Class` or its subclasses `TF2Engineer`, `TF2Medic`, `TF2Sniper` or `TF2Spy` depending on the given XML data.

Parameters:

  • class_data (Hash<String, Object>)

    The XML data for the class

Returns:

  • (TF2Class)

    The statistics for the given class data



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/steam/community/tf2/tf2_class_factory.rb', line 25

def self.tf2_class(class_data)
  case class_data['className']
    when 'Engineer' then
      return TF2Engineer.new(class_data)
    when 'Medic' then
      return TF2Medic.new(class_data)
    when 'Sniper' then
      return TF2Sniper.new(class_data)
    when 'Spy' then
      return TF2Spy.new(class_data)
    else
      return TF2Class.new(class_data)
  end
end