Class: TusurHeader::Link

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers
Defined in:
lib/tusur_header/menu_links.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, url, options, separator) ⇒ Link

Returns a new instance of Link.



7
8
9
# File 'lib/tusur_header/menu_links.rb', line 7

def initialize(title, url, options, separator)
  @title, @url, @options, @separator = title, url, options, separator
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/tusur_header/menu_links.rb', line 5

def options
  @options
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/tusur_header/menu_links.rb', line 5

def title
  @title
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/tusur_header/menu_links.rb', line 5

def url
  @url
end

Instance Method Details



15
16
17
# File 'lib/tusur_header/menu_links.rb', line 15

def link
   :li, link_to(title, url, options).html_safe
end

#separatorObject



23
24
25
# File 'lib/tusur_header/menu_links.rb', line 23

def separator
   :li, nil, class: 'divider'
end

#separator?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/tusur_header/menu_links.rb', line 19

def separator?
  !!@separator
end

#to_sObject



11
12
13
# File 'lib/tusur_header/menu_links.rb', line 11

def to_s
  (separator? ? separator : link) rescue ''
end