class Buoys::Link

Constants

CONFIG

Attributes

current[R]
options[RW]
options_for_config[RW]
text[RW]

Public Class Methods

new(text, url, options) click to toggle source
# 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

Public Instance Methods

current?() click to toggle source
# File lib/buoys/link.rb, line 25
def current?
  @current
end
mark_as_current!() click to toggle source
# File lib/buoys/link.rb, line 20
def mark_as_current!
  options[:class] = config[:current_class]
  @current = true
end
url() click to toggle source
# File lib/buoys/link.rb, line 29
def url
  return '' if current? && !config[:link_current]

  @_url || ''
end
url=(str) click to toggle source
# File lib/buoys/link.rb, line 35
def url=(str)
  @_url = str
end

Private Instance Methods

config() click to toggle source
# File lib/buoys/link.rb, line 41
def config
  CONFIG.merge(options_for_config)
end
extract_options_and_config(opts) click to toggle source
# File lib/buoys/link.rb, line 45
def extract_options_and_config(opts)
  options = opts.with_indifferent_access
  config = (options.keys & CONFIG.keys).each_with_object({}) {|key, hash|
    hash[key] = options.delete(key)
  }

  [config, options]
end