Class: Pulse::BreadcrumbItem
- Inherits:
-
Component
- Object
- Component
- Pulse::BreadcrumbItem
- Defined in:
- app/components/pulse/breadcrumb_item.rb
Overview
Renders a breadcrumb item
Constant Summary collapse
- DEFAULT_LINK_CLASSES =
'pulse-underline'- DEFAULT_TEXT_CLASSES =
''
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text:, href: nil, **system_arguments) ⇒ BreadcrumbItem
constructor
A new instance of BreadcrumbItem.
- #link? ⇒ Boolean
Constructor Details
#initialize(text:, href: nil, **system_arguments) ⇒ BreadcrumbItem
Returns a new instance of BreadcrumbItem.
11 12 13 14 15 16 |
# File 'app/components/pulse/breadcrumb_item.rb', line 11 def initialize(text:, href: nil, **system_arguments) @text = text @href = href @classes = system_arguments[:classes] @system_arguments = system_arguments.except(:classes) end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
9 10 11 |
# File 'app/components/pulse/breadcrumb_item.rb', line 9 def href @href end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'app/components/pulse/breadcrumb_item.rb', line 9 def text @text end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/components/pulse/breadcrumb_item.rb', line 22 def call if link? link_to(@text, @href, class: link_classes, **@system_arguments) else content_tag(:span, @text, class: text_classes, **@system_arguments) end end |
#link? ⇒ Boolean
18 19 20 |
# File 'app/components/pulse/breadcrumb_item.rb', line 18 def link? @href.present? end |