Class: Refinery::Menu
- Inherits:
-
Object
- Object
- Refinery::Menu
- Defined in:
- lib/refinery/menu.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
Instance Method Summary collapse
- #append(objects) ⇒ Object
-
#initialize(objects = nil) ⇒ Menu
constructor
A new instance of Menu.
- #roots ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(objects = nil) ⇒ Menu
Returns a new instance of Menu.
4 5 6 |
# File 'lib/refinery/menu.rb', line 4 def initialize(objects = nil) append(objects) end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
15 16 17 |
# File 'lib/refinery/menu.rb', line 15 def items @items end |
Instance Method Details
#append(objects) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/refinery/menu.rb', line 8 def append(objects) Array(objects).each do |item| item = item. if item.respond_to?(:to_refinery_menu_item) items << MenuItem.new(self, item) end end |
#roots ⇒ Object
21 22 23 |
# File 'lib/refinery/menu.rb', line 21 def roots @roots ||= select { |item| item.orphan? && item.depth == minimum_depth } end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/refinery/menu.rb', line 25 def to_s map(&:title).join(' ') end |