Class: Georgia::MenuAncestryParser

Inherits:
Object
  • Object
show all
Defined in:
app/parsers/georgia/menu_ancestry_parser.rb

Defined Under Namespace

Classes: LinkAttributes

Instance Method Summary collapse

Constructor Details

#initialize(serialized_string) ⇒ MenuAncestryParser

Returns a new instance of MenuAncestryParser.



4
5
6
# File 'app/parsers/georgia/menu_ancestry_parser.rb', line 4

def initialize serialized_string
  @ancestry = serialized_string
end

Instance Method Details

#to_hashObject



8
9
10
11
12
13
14
15
16
# File 'app/parsers/georgia/menu_ancestry_parser.rb', line 8

def to_hash
  pairs = split_parent_child_pairs
  parsed_hash = {}
  pairs.each_with_index do |p, index|
    attributes = LinkAttributes.new(p)
    parsed_hash[attributes.id] = {position: index+1, parent_id: attributes.parent_id}
  end
  parsed_hash
end