Class: Interview::Button

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

Instance Attribute Summary collapse

Attributes included from HasControls

#controls

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods included from HasControls

#add_control, #add_controls, included, #siblings

Methods inherited from Control

#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #set_attributes, #set_defaults

Constructor Details

#initialize(params = {}) ⇒ Button

Returns a new instance of Button.



8
9
10
11
# File 'lib/interview/button.rb', line 8

def initialize(params={})
  @html_class = []
  super
end

Instance Attribute Details

#captionObject

Returns the value of attribute caption.



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

def caption
  @caption
end

#html_classObject (readonly)

Returns the value of attribute html_class.



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

def html_class
  @html_class
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#styleObject

Returns the value of attribute style.



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

def style
  @style
end

#submitObject

Returns the value of attribute submit.



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

def submit
  @submit
end

Instance Method Details

#renderObject



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

def render
  html_class = @html_class
  if @style.to_s == 'primary'
    html_class << 'btn btn-primary'
  else
    html_class << 'btn btn-default'
  end
    
  if @submit
    h.submit_tag @caption, name: @name, class: @html_class.join(' ')
  else
    h.button_tag @caption, name: @name, class: @html_class.join(' ')
  end
end