class SeatGeek::Taxonomies::Tree
Constants
- FILE_PATH
Attributes
parent_ids[RW]
taxonomies[RW]
Public Class Methods
new(parent_ids:, taxonomies:)
click to toggle source
# File lib/seat_geek/taxonomies/tree.rb, line 5 def initialize(parent_ids:, taxonomies:) @parent_ids = parent_ids @taxonomies = taxonomies build_tree end
Public Instance Methods
all()
click to toggle source
# File lib/seat_geek/taxonomies/tree.rb, line 11 def all finished_tree end
concert()
click to toggle source
# File lib/seat_geek/taxonomies/tree.rb, line 19 def concert finished_tree[:concert] end
sports()
click to toggle source
# File lib/seat_geek/taxonomies/tree.rb, line 15 def sports finished_tree[:sports] end
theater()
click to toggle source
# File lib/seat_geek/taxonomies/tree.rb, line 23 def theater finished_tree[:theater] end
Private Instance Methods
build_tree()
click to toggle source
# File lib/seat_geek/taxonomies/tree.rb, line 31 def build_tree parent_ids.each do |parent_id| parent_object = taxonomies.detect { |taxonomy| taxonomy['id'] == parent_id } child_taxonomies = [parent_object] taxonomies.each do |taxonomy| child_taxonomies << taxonomy if taxonomy['parent_id'].to_s[0] == parent_id.to_s[0] end parent_object_name = parent_object['name'].to_sym finished_tree[parent_object_name] = tree_klass[parent_object_name].new(child_taxonomies: child_taxonomies, file_path: FILE_PATH, type: parent_object['name']) end end
finished_tree()
click to toggle source
# File lib/seat_geek/taxonomies/tree.rb, line 51 def finished_tree @finished_tree ||= { sports: nil, concert: nil, theater: nil } end
tree_klass()
click to toggle source
# File lib/seat_geek/taxonomies/tree.rb, line 47 def tree_klass { sports: SeatGeek::Taxonomies::Sports, concert: SeatGeek::Taxonomies::Concert, theater: SeatGeek::Taxonomies::Theater } end