Sha256: 9137104d619f3ce415dc46f9b1a75b660b25228c2622128434d0faa80dc0cf8b
Contents?: true
Size: 1.27 KB
Versions: 8
Compression:
Stored size: 1.27 KB
Contents
require "triviacrack/category_statistics" # Internal: This module is used to parse data returned from the Trivia Crack API # into a ruby object that represents category statistics for a Trivia Crack # game. module TriviaCrack module Parsers module CategoryStatisticsParser # Internal: Parses data returned from the Trivia Crack API to create # TriviaCrack::CategoryStatistics objects. # # raw_data - A hash of the raw data returned by the Trivia Crack API. # # Examples # # raw_data = get_raw_data_from_API # ... # stats = TriviaCrack::Parsers::CategoryStatisticsParser.parse raw_data # # Returns a hash of TriviaCrack::CategoryStatistics objects, keyed by # category. def self.parse(raw_data) categories = {} if raw_data raw_data.each do |category| category_name = category["category"].downcase.to_sym categories[category_name] = TriviaCrack::CategoryStatistics.new( category: category_name, correct: category["correct"], incorrect: category["incorrect"], worst: category["worst"] ) end end categories end end end end
Version data entries
8 entries across 8 versions & 1 rubygems