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

Attributes inherited from Tag

#options, #tag_name

Instance Method Summary (collapse)

Constructor Details

- (Link) initialize(href, options = {})

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

Raises:

  • (TypeError)


7
8
9
10
11
# File 'lib/it/link.rb', line 7

def initialize(href, options = {})
  raise TypeError, "Invalid href given" unless href.is_a?(Hash) || href.is_a?(String)
  super(:a, options)
  @href = href
end

Instance Method Details

- (Object) process(content)

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



14
15
16
# File 'lib/it/link.rb', line 14

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