Class: Xebec::NavBar
- Inherits:
-
Object
- Object
- Xebec::NavBar
- Defined in:
- lib/xebec/nav_bar.rb
Constant Summary collapse
- DEFAULT_NAME =
:default
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#html_attributes ⇒ Object
readonly
Returns the value of attribute html_attributes.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(name = nil, html_attributes = nil) ⇒ NavBar
constructor
Create a new NavBar object.
- #inspect ⇒ Object
-
#nav_item(name, href = nil) ⇒ Object
Add a navigation item to this bar.
- #to_s ⇒ Object
Constructor Details
#initialize(name = nil, html_attributes = nil) ⇒ NavBar
Create a new NavBar object.
19 20 21 22 23 24 |
# File 'lib/xebec/nav_bar.rb', line 19 def initialize(name = nil, html_attributes = nil) @name = name || DEFAULT_NAME @html_attributes = html_attributes || {} @items = [] @current = nil end |
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
12 13 14 |
# File 'lib/xebec/nav_bar.rb', line 12 def current @current end |
#html_attributes ⇒ Object (readonly)
Returns the value of attribute html_attributes.
11 12 13 |
# File 'lib/xebec/nav_bar.rb', line 11 def html_attributes @html_attributes end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
10 11 12 |
# File 'lib/xebec/nav_bar.rb', line 10 def items @items end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/xebec/nav_bar.rb', line 9 def name @name end |
Instance Method Details
#empty? ⇒ Boolean
40 41 42 |
# File 'lib/xebec/nav_bar.rb', line 40 def empty? items.empty? end |
#inspect ⇒ Object
48 49 50 |
# File 'lib/xebec/nav_bar.rb', line 48 def inspect "<NavBar #{name}: #{items.map(&:name).join('|')}>" end |
#nav_item(name, href = nil) ⇒ Object
Add a navigation item to this bar.
To customize the link text, set the internationalization key navbar.{{nav bar name}}.{{nav item name}}
.
36 37 38 |
# File 'lib/xebec/nav_bar.rb', line 36 def nav_item(name, href = nil) items << Xebec::NavItem.new(name, href) end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/xebec/nav_bar.rb', line 44 def to_s "<NavBar #{name}>" end |