Class: Interview::Button
- Includes:
- HasControls
- Defined in:
- lib/interview/button.rb
Instance Attribute Summary collapse
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#html_class ⇒ Object
readonly
Returns the value of attribute html_class.
-
#name ⇒ Object
Returns the value of attribute name.
-
#style ⇒ Object
Returns the value of attribute style.
-
#submit ⇒ Object
Returns the value of attribute submit.
Attributes included from HasControls
Attributes inherited from Control
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Button
constructor
A new instance of Button.
- #render ⇒ Object
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
#caption ⇒ Object
Returns the value of attribute caption.
5 6 7 |
# File 'lib/interview/button.rb', line 5 def caption @caption end |
#html_class ⇒ Object (readonly)
Returns the value of attribute html_class.
6 7 8 |
# File 'lib/interview/button.rb', line 6 def html_class @html_class end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/interview/button.rb', line 5 def name @name end |
#style ⇒ Object
Returns the value of attribute style.
5 6 7 |
# File 'lib/interview/button.rb', line 5 def style @style end |
#submit ⇒ Object
Returns the value of attribute submit.
5 6 7 |
# File 'lib/interview/button.rb', line 5 def submit @submit end |
Instance Method Details
#render ⇒ Object
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. @caption, name: @name, class: @html_class.join(' ') end end |