Class: HS::Link

Inherits:
Element show all
Defined in:
lib/hs/elements/link.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#children, #class_name, #style

Instance Method Summary collapse

Methods inherited from Element

#initialize, #preview

Methods included from ElementPreview

#element_preview, #text_preview

Constructor Details

This class inherits a constructor from HS::Element

Instance Attribute Details

#toObject

Returns the value of attribute to.



5
6
7
# File 'lib/hs/elements/link.rb', line 5

def to
  @to
end

Instance Method Details

#hrefObject



15
16
17
18
19
# File 'lib/hs/elements/link.rb', line 15

def href
  return to if to =~ %r{^http(s)?://}
  return to if to.start_with?('/')
  "/#{to}"
end

#paramsObject



11
12
13
# File 'lib/hs/elements/link.rb', line 11

def params
  super.merge(href: href)
end

#tag_nameObject



7
8
9
# File 'lib/hs/elements/link.rb', line 7

def tag_name
  'a'
end