lib/triviacrack/parsers/question_parser.rb in triviacrack-0.6.0 vs lib/triviacrack/parsers/question_parser.rb in triviacrack-0.7.0
- old
+ new
@@ -1,13 +1,14 @@
-require "triviacrack/question"
+# frozen_string_literal: true
+require 'triviacrack/question'
+
# Internal: This module is used to parse data returned from the Trivia Crack API
# into a ruby object that represents a Trivia Crack question.
module TriviaCrack
module Parsers
module QuestionParser
-
# Internal: Parses data returned from the Trivia Crack API to create a
# TriviaCrack::Question object.
#
# raw_data - A hash of the raw data returned by the Trivia Crack API.
#
@@ -18,19 +19,18 @@
# question = TriviaCrack::Parsers::QuestionParser.parse raw_data
#
# Returns a TriviaCrack::Question.
def self.parse(raw_data)
TriviaCrack::Question.new(
- id: raw_data["id"],
- type: raw_data["type"].downcase.to_sym,
- category: raw_data["category"].downcase.to_sym,
- text: raw_data["text"],
- answers: raw_data["answers"],
- correct_answer: raw_data["correct_answer"],
- media_type: raw_data["media_type"].downcase.to_sym,
- image_url: raw_data["base_url"]
+ id: raw_data['id'],
+ type: raw_data['type'].downcase.to_sym,
+ category: raw_data['category'].downcase.to_sym,
+ text: raw_data['text'],
+ answers: raw_data['answers'],
+ correct_answer: raw_data['correct_answer'],
+ media_type: raw_data['media_type'].downcase.to_sym,
+ image_url: raw_data['base_url']
)
end
-
end
end
end