Sha256: c09e30eb94c281c269fe7abf2b7e1f06ec8cdb96840d34a6b73ab74ff0389cb4
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true 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
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
buoys-2.1.0 | lib/buoys/link.rb |
buoys-2.0.2 | lib/buoys/link.rb |
buoys-2.0.1 | lib/buoys/link.rb |
buoys-2.0.0 | lib/buoys/link.rb |
buoys-1.1.0 | lib/buoys/link.rb |
buoys-1.0.0 | lib/buoys/link.rb |