Class: Steam::Id::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/steam/id/base.rb

Overview

Represents a SteamID holds the various parts of the Steam Id an internal 64bit datastructure

Direct Known Subclasses

CommunityId, Steam2Id, Steam3Id

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(struct = Struct.new) ⇒ Base

Create a new Steam ID



20
21
22
# File 'lib/steam/id/base.rb', line 20

def initialize(struct = Struct.new)
  @struct = struct
end

Instance Attribute Details

#structObject (readonly)

Returns the value of attribute struct.



17
18
19
# File 'lib/steam/id/base.rb', line 17

def struct
  @struct
end

Instance Method Details

#to_iInteger

Return the Steam Id in int format.

Returns:

  • (Integer)

    the steam id in int format



37
38
39
# File 'lib/steam/id/base.rb', line 37

def to_i
  @struct.to_i
end

#to_s(klass = Steam2Printer) ⇒ String

Return the Steam Id in string format. By default the Steam2 format is returned

Parameters:

  • klass (Printer) (defaults to: Steam2Printer)

    a steam id printer

Returns:

  • (String)

    the steam id in the desired format



29
30
31
32
# File 'lib/steam/id/base.rb', line 29

def to_s(klass = Steam2Printer)
  printer ||= klass.new(self)
  printer.print
end

#valid?Bool

Returns true if the Steam id is valid

Returns:

  • (Bool)

    true if valid, otherwise false



44
45
46
# File 'lib/steam/id/base.rb', line 44

def valid?
  valid_universe? && valid_account?
end