lib/triviacrack/parsers/session_parser.rb in triviacrack-0.6.0 vs lib/triviacrack/parsers/session_parser.rb in triviacrack-0.7.0
- old
+ new
@@ -1,14 +1,15 @@
-require "triviacrack/session"
-require "triviacrack/parsers/time_parser"
+# frozen_string_literal: true
+require 'triviacrack/session'
+require 'triviacrack/parsers/time_parser'
+
# Internal: This module is used to parse data returned from the Trivia Crack API
# into a ruby object that represents a Trivia Crack session.
module TriviaCrack
module Parsers
module SessionParser
-
# Internal: Parses data returned from the Trivia Crack API to create a
# TriviaCrack::Session object.
#
# raw_data - A hash of the raw data returned by the Trivia Crack API.
#
@@ -18,19 +19,18 @@
# ...
# session = TriviaCrack::Parsers::SessionParser.parse raw_data
#
# Returns a TriviaCrack::Session.
def self.parse(raw_data)
- expiration = TimeParser.parse raw_data["session"]["expirationTime"]
+ expiration = TimeParser.parse raw_data['session']['expirationTime']
TriviaCrack::Session.new(
- session_id: raw_data["session"]["session"],
- user_id: raw_data["id"],
- username: raw_data["username"],
- device_key: raw_data["session"]["deviceKey"],
+ session_id: raw_data['session']['session'],
+ user_id: raw_data['id'],
+ username: raw_data['username'],
+ device_key: raw_data['session']['deviceKey'],
expiration: expiration
)
end
-
end
end
-end
\ No newline at end of file
+end