Sha256: 58cb27745d6fa0d83cd6e97ed46db63084862861b0a309e5aa66f1a76b3d4450
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
module Buoys class Link attr_accessor :text, :options, :options_for_config attr_reader :current CONFIG = { current_class: (Buoys::Config.current_class || 'active'), link_current: (Buoys::Config.link_current || false) }.with_indifferent_access def initialize(text, url, options) @options_for_config, @options = extract_options_and_config(options) @text = text @_url = url @current = false end def mark_as_current! options[:class] = config[:current_class] @current = true end def current? @current end def url return '' if current? && !config[:link_current] @_url || '' end def url=(str) @_url = str end private def config CONFIG.merge(options_for_config) end 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 end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
buoys-0.6.0 | lib/buoys/link.rb |
buoys-0.5.0 | lib/buoys/link.rb |
buoys-0.4.0 | lib/buoys/link.rb |
buoys-0.3.0 | lib/buoys/link.rb |