Class: Shoehorn::Components::Navigation

Inherits:
Base
  • Object
show all
Defined in:
lib/shoehorn/components/navigation.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #output_buffer

Instance Method Summary collapse

Constructor Details

#initialize(elements, options = {}) ⇒ Navigation

Returns a new instance of Navigation.



5
6
7
8
# File 'lib/shoehorn/components/navigation.rb', line 5

def initialize(elements, options = {})
  super
  @elements = elements
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



3
4
5
# File 'lib/shoehorn/components/navigation.rb', line 3

def collection
  @collection
end

Instance Method Details

#to_sObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/shoehorn/components/navigation.rb', line 10

def to_s
  output_buffer << (:ul, :class => build_class) do
    html = ""

    @elements.each do |e|
      html_class = build_html_class(e)
      html << (:li, e.to_s, html_class)
    end

    html.html_safe
  end
  super
end