Class: Interview::Dropdown
- Includes:
- HasControls
- Defined in:
- lib/interview/dropdown.rb
Instance Attribute Summary collapse
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#html_class ⇒ Object
Returns the value of attribute html_class.
-
#image ⇒ Object
Returns the value of attribute image.
-
#style ⇒ Object
Returns the value of attribute style.
Attributes included from HasControls
Attributes inherited from Control
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Dropdown
constructor
A new instance of Dropdown.
- #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 = {}) ⇒ Dropdown
Returns a new instance of Dropdown.
7 8 9 10 |
# File 'lib/interview/dropdown.rb', line 7 def initialize(params={}) @html_class = [] super end |
Instance Attribute Details
#caption ⇒ Object
Returns the value of attribute caption.
5 6 7 |
# File 'lib/interview/dropdown.rb', line 5 def caption @caption end |
#html_class ⇒ Object
Returns the value of attribute html_class.
5 6 7 |
# File 'lib/interview/dropdown.rb', line 5 def html_class @html_class end |
#image ⇒ Object
Returns the value of attribute image.
5 6 7 |
# File 'lib/interview/dropdown.rb', line 5 def image @image end |
#style ⇒ Object
Returns the value of attribute style.
5 6 7 |
# File 'lib/interview/dropdown.rb', line 5 def style @style end |
Instance Method Details
#render ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/interview/dropdown.rb', line 12 def render html = Builder::XmlMarkup.new html_class = @html_class.dup html_class << 'dropdown' html.div class: html_class.join(' ') do html_class = 'dropdown-toggle' html_class += ' btn btn-default' if @style == 'button' html.a class: html_class, href: '#', :'data-toggle' => 'dropdown' do html.span '', class: "glyphicon glyphicon-#{@image}" if @image html.text! ' ' if @image and @caption html.text! @caption if @caption html.text! ' ' if @caption html.span '', class: 'caret' end html.ul class: 'dropdown-menu' do @controls.each do |control| html.li do html << control.render end end end end return html.target! end |