Class: Steam::Id::Steam2IdParser

Inherits:
Object
  • Object
show all
Defined in:
lib/steam/id/steam2_id_parser.rb

Overview

Parse a steam 2 id string

Constant Summary collapse

STEAM2_REGEX =

A Regex representing a valid Steam 2 string rubocop:disable LineLength

/STEAM_(?<universe>[0-4]):(?<authserver>[0-1]):(?<accountid>\d+)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Steam2IdParser

Returns a new instance of Steam2IdParser.



11
12
13
14
15
16
# File 'lib/steam/id/steam2_id_parser.rb', line 11

def initialize(id)
  @id = id.to_s
  @universe = EUniverse::INVALID
  @account_id = 0
  @auth_server = 0
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



9
10
11
# File 'lib/steam/id/steam2_id_parser.rb', line 9

def 
  @account_id
end

#auth_serverObject (readonly)

Returns the value of attribute auth_server.



9
10
11
# File 'lib/steam/id/steam2_id_parser.rb', line 9

def auth_server
  @auth_server
end

#universeObject (readonly)

Returns the value of attribute universe.



9
10
11
# File 'lib/steam/id/steam2_id_parser.rb', line 9

def universe
  @universe
end

Instance Method Details

#parseObject

Parse a Steam2Id from a given input string



19
20
21
22
23
24
# File 'lib/steam/id/steam2_id_parser.rb', line 19

def parse
  return unless matches
  @universe   = Integer(matches['universe'])
  @account_id = Integer(matches['accountid'])
  @auth_server = Integer(matches['authserver'])
end