I’m new to Ruby and I’m writing a pure Ruby script, not Rails.
This script is trivial:
require 'progressbar'
bar = ProgressBar.new("Example progress", 50)
total = 0
until total >= 50
sleep(rand(2)/2.0)
increment = (rand(6) + 3)
bar.inc(increment)
total += increment
end
When I run it, I get this:
./progressbar.rb:3: uninitialized constant ProgressBar (NameError)
from progressbar.rb:1:in `require'
from progressbar.rb:1
The gem is installed. What am I doing wrong?
Assuming you are on Ruby 1.8, I would rename the file you’ve in the question from
progressbar.rbtopg_test.rbor anything other thanprogressbar.rb.In the shell: