Class: Buoys::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/buoys/link.rb

Constant Summary collapse

CONFIG =
{
  current_class: (Buoys::Config.current_class || 'active'),
  link_current: (Buoys::Config.link_current || false)
}.with_indifferent_access

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, url, options) ⇒ Link

Returns a new instance of Link.



11
12
13
14
15
16
# File 'lib/buoys/link.rb', line 11

def initialize(text, url, options)
  @options_for_config, @options = extract_options_and_config(options)
  @text = text
  @_url = url
  @current = false
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



4
5
6
# File 'lib/buoys/link.rb', line 4

def current
  @current
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/buoys/link.rb', line 3

def options
  @options
end

#options_for_configObject

Returns the value of attribute options_for_config.



3
4
5
# File 'lib/buoys/link.rb', line 3

def options_for_config
  @options_for_config
end

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/buoys/link.rb', line 3

def text
  @text
end

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/buoys/link.rb', line 23

def current?
  @current
end

#mark_as_current!Object



18
19
20
21
# File 'lib/buoys/link.rb', line 18

def mark_as_current!
  options[:class] = config[:current_class]
  @current = true
end

#urlObject



27
28
29
30
31
# File 'lib/buoys/link.rb', line 27

def url
  return '' if current? && !config[:link_current]

  @_url || ''
end

#url=(str) ⇒ Object



33
34
35
# File 'lib/buoys/link.rb', line 33

def url=(str)
  @_url = str
end