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.



13
14
15
16
17
18
# File 'lib/buoys/link.rb', line 13

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.



6
7
8
# File 'lib/buoys/link.rb', line 6

def current
  @current
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

#options_for_configObject

Returns the value of attribute options_for_config.



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

def options_for_config
  @options_for_config
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/buoys/link.rb', line 25

def current?
  @current
end

#mark_as_current!Object



20
21
22
23
# File 'lib/buoys/link.rb', line 20

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

#urlObject



29
30
31
32
33
# File 'lib/buoys/link.rb', line 29

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

  @_url || ''
end

#url=(str) ⇒ Object



35
36
37
# File 'lib/buoys/link.rb', line 35

def url=(str)
  @_url = str
end