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.
11 12 13 14 15 16 |
# File 'lib/buoys/link.rb', line 11 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.
4 5 6 |
# File 'lib/buoys/link.rb', line 4 def current @current end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/buoys/link.rb', line 3 def @options end |
#options_for_config ⇒ Object
Returns the value of attribute options_for_config.
3 4 5 |
# File 'lib/buoys/link.rb', line 3 def @options_for_config end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/buoys/link.rb', line 3 def text @text end |
Instance Method Details
#current? ⇒ Boolean
23 24 25 |
# File 'lib/buoys/link.rb', line 23 def current? @current end |
#mark_as_current! ⇒ Object
18 19 20 21 |
# File 'lib/buoys/link.rb', line 18 def mark_as_current! [:class] = config[:current_class] @current = true end |
#url ⇒ Object
27 28 29 30 31 |
# File 'lib/buoys/link.rb', line 27 def url return '' if current? && !config[:link_current] @_url || '' end |
#url=(str) ⇒ Object
33 34 35 |
# File 'lib/buoys/link.rb', line 33 def url=(str) @_url = str end |