Class: Gdshowsdb::SetYAMLParser

Inherits:
Object
  • Object
show all
Defined in:
lib/gdshowsdb/set_yaml_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(show_list) ⇒ SetYAMLParser

Returns a new instance of SetYAMLParser.



7
8
9
# File 'lib/gdshowsdb/set_yaml_parser.rb', line 7

def initialize(show_list)
  @show_list = show_list
end

Class Method Details

.from_yaml(year) ⇒ Object



3
4
5
# File 'lib/gdshowsdb/set_yaml_parser.rb', line 3

def self.from_yaml(year)
  SetYAMLParser.new(Gdshowsdb.load_yaml_for_year(year))
end

Instance Method Details

#parseObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gdshowsdb/set_yaml_parser.rb', line 11

def parse      
  parsed_sets = []
  
  @show_list.each do |show_date, show| 
    sets = show[:sets]
    if sets && !sets.empty?
      sets.each_with_index do |set, i|
        parsed_sets.push(
          {uuid: set[:uuid], show_uuid: show[:uuid], position: i, encore: ShowSet.encore?(sets, set)}
        )
      end
    end
  end

  parsed_sets
end