Class: It::Link

Inherits:
Tag
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
lib/it/link.rb

Overview

A class for links

Instance Attribute Summary collapse

Attributes inherited from Tag

#options, #tag_name

Instance Method Summary collapse

Constructor Details

#initialize(href, options = {}) ⇒ Link

See It.link for details. You can do everything there and save 6 characters.

Raises:

  • (TypeError)


9
10
11
12
13
14
# File 'lib/it/link.rb', line 9

def initialize(href, options = {})
  raise TypeError, 'Invalid href given' unless [Hash, String, ActiveSupport::SafeBuffer].include?(href.class)

  super(:a, options)
  @href = href
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



6
7
8
# File 'lib/it/link.rb', line 6

def href
  @href
end

Instance Method Details

#process(content) ⇒ Object

Will be called from inside the helper to return the tag with the given content.



17
18
19
# File 'lib/it/link.rb', line 17

def process(content)
  link_to(content, href, options)
end