Class: Breadcrumbs::List
- Inherits:
-
Object
- Object
- Breadcrumbs::List
- Defined in:
- lib/breadcrumbs/list.rb
Instance Method Summary collapse
-
#initialize(all) ⇒ List
constructor
A new instance of List.
- #to_a(name) ⇒ Object
Constructor Details
#initialize(all) ⇒ List
Returns a new instance of List.
3 4 5 |
# File 'lib/breadcrumbs/list.rb', line 3 def initialize(all) @all = all end |
Instance Method Details
#to_a(name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/breadcrumbs/list.rb', line 7 def to_a(name) list = [] list << @all.find { |b| b["name"] == name } loop do if list.first["parent"] list.prepend(@all.find { |b| b["name"] === list.first["parent"] }) else break end end list end |