Parent

Files

ProgressBar::Components::Bar

Attributes

length[RW]
progress_mark[RW]
remainder_mark[RW]
unknown_progress_animation_steps[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/ruby-progressbar/components/bar.rb, line 15
def initialize(options = {})
  super

  self.unknown_progress_animation_steps = options[:unknown_progress_animation_steps] || DEFAULT_UNKNOWN_PROGRESS_ANIMATION_STEPS
  self.progress_mark                    = options[:progress_mark]                    || DEFAULT_PROGRESS_MARK
  self.remainder_mark                   = options[:remainder_mark]                   || DEFAULT_REMAINDER_MARK
end

Public Instance Methods

empty_string() click to toggle source
# File lib/ruby-progressbar/components/bar.rb, line 39
def empty_string
  incomplete_length = (length - completed_length)

  if total.nil?
    current_animation_step = progress % unknown_progress_animation_steps.size
    animation_graphic      = unknown_progress_animation_steps[current_animation_step]

    unknown_incomplete_string = animation_graphic * ((incomplete_length / unknown_progress_animation_steps.size) + 2)

    unknown_incomplete_string[0, incomplete_length]
  else
    remainder_mark * incomplete_length
  end
end
integrated_percentage_complete_string() click to toggle source
# File lib/ruby-progressbar/components/bar.rb, line 29
def integrated_percentage_complete_string
  return standard_complete_string if completed_length < 5

  " #{percentage_completed} ".to_s.center(completed_length, progress_mark)
end
standard_complete_string() click to toggle source
# File lib/ruby-progressbar/components/bar.rb, line 35
def standard_complete_string
  progress_mark * completed_length
end
to_s(options = {:format => :standard}) click to toggle source
# File lib/ruby-progressbar/components/bar.rb, line 23
def to_s(options = {:format => :standard})
  completed_string = send(:"#{options[:format]}_complete_string")

  "#{completed_string}#{empty_string}"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.