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.
-
#current_is_link ⇒ Object
Returns the value of attribute current_is_link.
-
#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, html_options = {}) ⇒ 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.
20 21 22 23 24 25 26 |
# File 'lib/xebec/nav_bar.rb', line 20 def initialize(name = nil, html_attributes = nil) @name = name || DEFAULT_NAME @html_attributes = html_attributes || {} @items = [] @current = nil @current_is_link = Xebec.current_is_link 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 |
#current_is_link ⇒ Object
Returns the value of attribute current_is_link.
13 14 15 |
# File 'lib/xebec/nav_bar.rb', line 13 def current_is_link @current_is_link 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
43 44 45 |
# File 'lib/xebec/nav_bar.rb', line 43 def empty? items.empty? end |
#inspect ⇒ Object
51 52 53 |
# File 'lib/xebec/nav_bar.rb', line 51 def inspect "<NavBar #{name}: #{items.map(&:name).join('|')}>" end |
#nav_item(name, href = nil, html_options = {}) ⇒ Object
Add a navigation item to this bar.
To customize the link text, set the internationalization key navbar.{{nav bar name}}.{{nav item name}}
.
39 40 41 |
# File 'lib/xebec/nav_bar.rb', line 39 def nav_item(name, href = nil, = {}) items << Xebec::NavItem.new(name, href, ) end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/xebec/nav_bar.rb', line 47 def to_s "<NavBar #{name}>" end |