Class: WrapIt::Link
- Includes:
- TextContainer
- Defined in:
- lib/wrap_it/link.rb
Overview
HTML link element
You can specify link by link, href or url option or by first String
argument. Also includes TextContainer module, so you can specify link
body with text or body option or by second String argument or inside
block.
Instance Method Summary collapse
-
#body ⇒ String
included
from TextContainer
Retrieves body text.
-
#href ⇒ String
Retrieves current link.
-
#href=(value) ⇒ String
(also: #link=, #url=)
Sets link.
Constructor Details
This class inherits a constructor from WrapIt::Base
Instance Method Details
#body ⇒ String Originally defined in module TextContainer
Retrieves body text
#href ⇒ String
Retrieves current link
41 42 43 |
# File 'lib/wrap_it/link.rb', line 41 def href html_attr[:href] end |
#href=(value) ⇒ String Also known as: link=, url=
Sets link
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/wrap_it/link.rb', line 50 def href=(value) if value.is_a?(Hash) WrapIt.rails? || fail( ArgumentError, 'Hash links supported only in Rails env' ) value = @template.url_for(value) end value.is_a?(String) || fail(ArgumentError, 'Wrong link type') html_attr[:href] = value end |