Class: PackwizardParser::CategoryParser

Inherits:
Object
  • Object
show all
Defined in:
lib/packwizard_parser/category_parser.rb

Overview

Parser for extracting category data from PackWizard JSON

Instance Method Summary collapse

Instance Method Details

#parse_all(data, item_parser:) ⇒ Array<Category>

Parse all categories from a PackWizard JSON

Parameters:

  • data (Hash)

    The parsed JSON response

  • item_parser (ItemParser)

    The parser used for extracting items from each category

Returns:

  • (Array<Category>)

    Array of extracted categories



11
12
13
14
15
16
17
18
19
20
# File 'lib/packwizard_parser/category_parser.rb', line 11

def parse_all(data, item_parser:)
  categories = []

  # tableData contains the arrays of each category
  data['tableData'].each do |category_data|
    category = parse(category_data, item_parser: item_parser)
    categories << category if category
  end
  categories
end