Class: Interview::Button

Inherits:
Control show all
Includes:
HasHtmlOptions
Defined in:
lib/interview/controls/button.rb

Instance Attribute Summary collapse

Attributes included from HasHtmlOptions

#html_class, #html_options

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods included from HasHtmlOptions

#initialize

Methods inherited from Control

#ancestors, #build_child, #build_with_params, #find_attribute, #find_attribute!, #initialize, #set_attributes, #set_defaults

Instance Attribute Details

#captionObject

Returns the value of attribute caption.



6
7
8
# File 'lib/interview/controls/button.rb', line 6

def caption
  @caption
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/interview/controls/button.rb', line 6

def name
  @name
end

#styleObject

Returns the value of attribute style.



6
7
8
# File 'lib/interview/controls/button.rb', line 6

def style
  @style
end

#submitObject

Returns the value of attribute submit.



6
7
8
# File 'lib/interview/controls/button.rb', line 6

def submit
  @submit
end

Instance Method Details

#build(b) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/interview/controls/button.rb', line 8

def build(b)
  html_class = @html_class.dup
  if @style.to_s == 'primary'
    html_class += %w(btn btn-primary)
  else
    html_class += %w(btn btn-default)
  end
  @html_options[:name] = @name
  
  if @submit
    b << h.submit_tag(@caption, options_to_html(@html_options, html_class))
  else
    b << h.button_tag(@caption, options_to_html(@html_options, html_class))
  end
end