Class: Buoys::Link
- Inherits:
-
Object
- Object
- Buoys::Link
- 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
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#options ⇒ Object
Returns the value of attribute options.
-
#options_for_config ⇒ Object
Returns the value of attribute options_for_config.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #current? ⇒ Boolean
-
#initialize(text, url, options) ⇒ Link
constructor
A new instance of Link.
- #mark_as_current! ⇒ Object
- #url ⇒ Object
- #url=(str) ⇒ Object
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_for_config, @options = () @text = text @_url = url @current = false end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
6 7 8 |
# File 'lib/buoys/link.rb', line 6 def current @current end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/buoys/link.rb', line 5 def @options end |
#options_for_config ⇒ Object
Returns the value of attribute options_for_config.
5 6 7 |
# File 'lib/buoys/link.rb', line 5 def @options_for_config end |
#text ⇒ Object
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
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! [:class] = config[:current_class] @current = true end |
#url ⇒ Object
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 |