Class: Padrino::Helpers::Breadcrumb
- Inherits:
-
Object
- Object
- Padrino::Helpers::Breadcrumb
- Defined in:
- lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.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) ⇒ Object
(also: #<<)
Add a new breadcrumbs.
-
#del(name) ⇒ Object
Remove a Breadcrumbs.
-
#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) ⇒ Object
Set the custom home (Parent) link.
Constructor Details
#initialize ⇒ Breadcrumb
initialize breadcrumbs with default value
20 21 22 23 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb', line 20 def initialize self.home = { :url => DEFAULT_URL, :caption => DEFAULT_CAPTION, :name => :home } reset end |
Instance Attribute Details
#home ⇒ Object
Returns the value of attribute home.
5 6 7 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb', line 5 def home @home end |
#items ⇒ Object
Returns the value of attribute items.
6 7 8 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb', line 6 def items @items end |
Instance Method Details
#add(name, url, caption) ⇒ Object Also known as: <<
Add a new breadcrumbs
87 88 89 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb', line 87 def add(name, url, ) items << { :name => name, :url => url.to_s, :caption => .to_s.humanize.html_safe } end |
#del(name) ⇒ Object
Remove a Breadcrumbs
107 108 109 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb', line 107 def del(name) items.delete_if { |item| item[:name] == name.to_sym } end |
#reset ⇒ Object
Reset breadcrumbs to default or personal home
51 52 53 54 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb', line 51 def reset self.items=[] self.items << home end |
#reset! ⇒ Object
Reset breadcrumbs to default home
63 64 65 66 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb', line 63 def reset! self.home = { :url => DEFAULT_URL, :caption => DEFAULT_CAPTION, :name => :home } reset end |
#set_home(url, caption) ⇒ Object
Set the custom home (Parent) link
39 40 41 42 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb', line 39 def set_home(url, ) self.home = { :url => url, :caption => .to_s.humanize.html_safe, :name => :home } reset end |