Class: Pulse::BreadcrumbItem

Inherits:
Component
  • Object
show all
Defined in:
app/components/pulse/breadcrumb_item.rb

Overview

Renders a breadcrumb item

Constant Summary collapse

'pulse-underline'
DEFAULT_TEXT_CLASSES =
''

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hrefObject (readonly)

Returns the value of attribute href.



9
10
11
# File 'app/components/pulse/breadcrumb_item.rb', line 9

def href
  @href
end

#textObject (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

#callObject



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
    (:span, @text, class: text_classes, **@system_arguments)
  end
end

#link?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/components/pulse/breadcrumb_item.rb', line 18

def link?
  @href.present?
end