Class: Interview::CollapseContainer

Inherits:
Control
  • Object
show all
Includes:
HasControls
Defined in:
lib/interview/collapse_container.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, #initialize, #siblings

Methods inherited from Control

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

Instance Attribute Details

#captionObject

Returns the value of attribute caption.



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

def caption
  @caption
end

Instance Method Details

#renderObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/interview/collapse_container.rb', line 7

def render
  html = Builder::XmlMarkup.new
  new_id = Time.now.to_f.to_s.delete('.')
  html << h.link_to(@caption, '#', class: 'collapse_link', data: { toggle: 'collapse', target: "##{new_id}" })
  html.div id: new_id, class: 'panel-collapse collapse' do
    @controls.each do |control|
      html << control.render
    end
  end
  return html.target!
end