Class: Shoehorn::Components::Button

Inherits:
Base
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
lib/shoehorn/components/button.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #output_buffer

Instance Method Summary collapse

Constructor Details

#initialize(text, link, options = {}) ⇒ Button

Returns a new instance of Button.



7
8
9
10
11
# File 'lib/shoehorn/components/button.rb', line 7

def initialize(text, link, options = {})
  super
  @text = text
  @link = url_for(link)
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/shoehorn/components/button.rb', line 5

def text
  @text
end

Instance Method Details

#to_sObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/shoehorn/components/button.rb', line 13

def to_s
  html_text = ""
  if options[:icon_name]
    html_text << build_icon.html_safe
  else
    html_text << text
  end
  html_text << ' ' << build_caret.html_safe if options[:dropdown]

  output_buffer << (:a, html_text.html_safe, build_tag_options).html_safe
  super
end