Class: Steam::Id::Steam2IdParser
- Inherits:
-
Object
- Object
- Steam::Id::Steam2IdParser
- 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
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#auth_server ⇒ Object
readonly
Returns the value of attribute auth_server.
-
#universe ⇒ Object
readonly
Returns the value of attribute universe.
Instance Method Summary collapse
-
#initialize(id) ⇒ Steam2IdParser
constructor
A new instance of Steam2IdParser.
-
#parse ⇒ Object
Parse a Steam2Id from a given input string.
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_id ⇒ Object (readonly)
Returns the value of attribute account_id.
9 10 11 |
# File 'lib/steam/id/steam2_id_parser.rb', line 9 def account_id @account_id end |
#auth_server ⇒ Object (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 |
#universe ⇒ Object (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
#parse ⇒ Object
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 |