Class: Steam::Id::Steam3IdParser
- Inherits:
-
Object
- Object
- Steam::Id::Steam3IdParser
- 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
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#type ⇒ Object
readonly
The type of account as an integer.
-
#universe ⇒ Object
readonly
Returns the value of attribute universe.
Instance Method Summary collapse
-
#initialize(id) ⇒ Steam3IdParser
constructor
A new instance of Steam3IdParser.
-
#instance ⇒ Object
The instance of the account.
-
#parse ⇒ Object
Create a Steam3 id by parsing an input string.
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_id ⇒ Object (readonly)
Returns the value of attribute account_id.
9 10 11 |
# File 'lib/steam/id/steam3_id_parser.rb', line 9 def account_id @account_id end |
#type ⇒ Object (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 |
#universe ⇒ Object (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
#instance ⇒ Object
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 |
#parse ⇒ Object
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 |