Class: MojComponent::SubNavigationComponent::NavigationItem

Inherits:
ApplicationComponent
  • Object
show all
Defined in:
app/components/moj_component/sub_navigation_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, href: "#", current: nil) ⇒ NavigationItem

Returns a new instance of NavigationItem.



10
11
12
13
14
15
# File 'app/components/moj_component/sub_navigation_component.rb', line 10

def initialize(text:, href: "#", current: nil)
  @text = text
  @href = href
  @current = current
  super()
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



8
9
10
# File 'app/components/moj_component/sub_navigation_component.rb', line 8

def current
  @current
end

#hrefObject (readonly)

Returns the value of attribute href.



8
9
10
# File 'app/components/moj_component/sub_navigation_component.rb', line 8

def href
  @href
end

#textObject (readonly)

Returns the value of attribute text.



8
9
10
# File 'app/components/moj_component/sub_navigation_component.rb', line 8

def text
  @text
end

Instance Method Details

#callObject



17
18
19
20
21
# File 'app/components/moj_component/sub_navigation_component.rb', line 17

def call
  tag.li class: "moj-sub-navigation__item" do
    link_to(text, href, class: "moj-sub-navigation__link", aria: current_override)
  end
end