Class: Georgia::MenuAncestryParser
- Inherits:
-
Object
- Object
- Georgia::MenuAncestryParser
- Defined in:
- app/parsers/georgia/menu_ancestry_parser.rb
Defined Under Namespace
Classes: LinkAttributes
Instance Method Summary collapse
-
#initialize(serialized_string) ⇒ MenuAncestryParser
constructor
A new instance of MenuAncestryParser.
- #to_hash ⇒ Object
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_hash ⇒ Object
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 |