Class: Steam::Id::Steam3IdParser

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

Overview

Parse a steam 3 id string

Constant Summary collapse

STEAM3_REGEX =

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

/\[(?<type>[AGMPCgcLTIUai]):(?<universe>[0-4]):(?<account>\d+)(:(?<instance>\d+))?\]/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Steam3IdParser

Returns a new instance of Steam3IdParser.



13
14
15
16
17
18
19
# File 'lib/steam/id/steam3_id_parser.rb', line 13

def initialize(id)
  @id = id.to_s
  @type = nil
  @account_id = 0
  @universe = EUniverse::INVALID
  @type = 'U'
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



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

def 
  @account_id
end

#typeObject (readonly)

The type of account as an integer



36
37
38
# File 'lib/steam/id/steam3_id_parser.rb', line 36

def type
  @type
end

#universeObject (readonly)

Returns the value of attribute universe.



10
11
12
# File 'lib/steam/id/steam3_id_parser.rb', line 10

def universe
  @universe
end

Instance Method Details

#instanceObject

The instance of the account. Currently only instance 1 is supported



31
32
33
# File 'lib/steam/id/steam3_id_parser.rb', line 31

def instance
  1
end

#parseObject

Create a Steam3 id by parsing an input string



22
23
24
25
26
27
28
# File 'lib/steam/id/steam3_id_parser.rb', line 22

def parse
  return unless matches

  @account_id = Integer(matches['account'])
  @universe = Integer(matches['universe'])
  @type = matches['type']
end