Class: Padrino::Contrib::Helpers::Breadcrumb
- Inherits:
-
Object
- Object
- Padrino::Contrib::Helpers::Breadcrumb
- Defined in:
- lib/padrino-contrib/helpers/breadcrumbs.rb
Constant Summary collapse
- DEFAULT_URL =
"/"
- DEFAULT_CAPTION =
"Home Page"
Instance Attribute Summary collapse
-
#home ⇒ Object
Returns the value of attribute home.
-
#items ⇒ Object
Returns the value of attribute items.
Instance Method Summary collapse
-
#add(name, url, caption, options = {}) ⇒ Object
(also: #<<)
Add a new breadcrumbs.
-
#del(name) ⇒ Object
Remove a breadcrumb.
-
#initialize ⇒ Breadcrumb
constructor
Initialize breadcrumbs with default value.
-
#reset ⇒ Object
Reset breadcrumbs to default or personal home.
-
#reset! ⇒ Object
Reset breadcrumbs to default home.
-
#set_home(url, caption, options = {}) ⇒ Object
Set the custom home (Parent) link.
Constructor Details
#initialize ⇒ Breadcrumb
Initialize breadcrumbs with default value.
18 19 20 |
# File 'lib/padrino-contrib/helpers/breadcrumbs.rb', line 18 def initialize reset! end |
Instance Attribute Details
#home ⇒ Object
Returns the value of attribute home.
5 6 7 |
# File 'lib/padrino-contrib/helpers/breadcrumbs.rb', line 5 def home @home end |
#items ⇒ Object
Returns the value of attribute items.
5 6 7 |
# File 'lib/padrino-contrib/helpers/breadcrumbs.rb', line 5 def items @items end |
Instance Method Details
#add(name, url, caption, options = {}) ⇒ Object Also known as: <<
Add a new breadcrumbs.
95 96 97 98 99 100 101 102 |
# File 'lib/padrino-contrib/helpers/breadcrumbs.rb', line 95 def add(name, url, caption, = {}) items << { :name => name.to_sym, :url => url.to_s, :caption => caption.to_s.humanize.html_safe, :options => } end |
#del(name) ⇒ Object
Remove a breadcrumb.
115 116 117 |
# File 'lib/padrino-contrib/helpers/breadcrumbs.rb', line 115 def del(name) items.delete_if { |item| item[:name] == name.to_sym } end |
#reset ⇒ Object
Reset breadcrumbs to default or personal home.
53 54 55 56 |
# File 'lib/padrino-contrib/helpers/breadcrumbs.rb', line 53 def reset self.items = [] self.items << home end |
#reset! ⇒ Object
Reset breadcrumbs to default home.
64 65 66 67 68 69 70 71 72 |
# File 'lib/padrino-contrib/helpers/breadcrumbs.rb', line 64 def reset! self.home = { :name => :home, :url => DEFAULT_URL, :caption => DEFAULT_CAPTION, :options => {} } reset end |
#set_home(url, caption, options = {}) ⇒ Object
Set the custom home (Parent) link.
37 38 39 40 41 42 43 44 45 |
# File 'lib/padrino-contrib/helpers/breadcrumbs.rb', line 37 def set_home(url, caption, = {}) self.home = { :url => url.to_s, :caption => caption.to_s.humanize.html_safe, :name => :home, :options => } reset end |