Class: Interview::ProgressBar

Inherits:
Control
  • Object
show all
Defined in:
lib/interview/progress_bar.rb

Instance Attribute Summary collapse

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods inherited from Control

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

Constructor Details

#initialize(params = {}) ⇒ ProgressBar

Returns a new instance of ProgressBar.



6
7
8
9
10
# File 'lib/interview/progress_bar.rb', line 6

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

Instance Attribute Details

#hiddenObject

Returns the value of attribute hidden.



4
5
6
# File 'lib/interview/progress_bar.rb', line 4

def hidden
  @hidden
end

#html_classObject

Returns the value of attribute html_class.



4
5
6
# File 'lib/interview/progress_bar.rb', line 4

def html_class
  @html_class
end

Instance Method Details

#renderObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/interview/progress_bar.rb', line 12

def render
  html_class = @html_class
  html = Builder::XmlMarkup.new
  opts = { class: "progress" }
  opts[:class] += " collapse" if @hidden
  opts[:class] += ' ' + @html_class.join(' ') unless @html_class.empty?
  html.div opts do
    html.div '', class: 'progress-bar bar', style: 'width: 0%'
  end
  return html.target!
end