The Accidental Rubyist

invalid byte sequence in UTF-8

progress bars in rbcurse

with 4 comments

progress bars

rbcurse has a progress bar – 2 styles, one is the colored one, and one the “classic” style.

Here’s the code for both (using the App class):

@pbar = progress :width => 20, :bgcolor => 'white', :color => 'red'
@pbar1 = progress :width => 20, :style => :old


Written by totalrecall

September 27, 2010 at 10:08 am

Posted in ruby

4 Responses

Subscribe to comments with RSS.

  1. What is the App class? RubyCurses::something module? Can you give a snippet of how to set up the progress helper? Include rprogress somehow?


    November 17, 2010 at 2:21 am

  2. Please see the examples dir.

    App is a class in RubyCurses. But what you do is:

    require ‘rbcurse/app’ do
    @pbar = progress :width => 20, :bgcolor => ‘white’, :color => ‘red’
    # application code here

    If you see app.rb there is an example of progress bars. You should be able to execute app.rb from commandline since it has a FILE clause.

    Also you can check the source of appemail.rb or appgmail.rb in examples.


    November 17, 2010 at 1:06 pm

  3. Thanks for the follow up. Trying to get multiple progress bars to work and some of the more simple ruby gems/libs don’t support it.


    November 17, 2010 at 7:51 pm

  4. Actually. I have still not frozen the App class. It has not surfaced in a gem yet.

    Until now I’ve made a bunch of demos. In all these the App is all contained inside the App block. All is fine. However, today i am trying something different and running into scope issues.

    class XXX def initialize end

    def mymethod end

    def run do stack do button do # here is where i am unable to access mymethod. # i am unable to access the instance of XXX end end end end

    I’ve changed App to do a “yield_or_eval” but that does not help. I pass the self to App when i instantiate it. => self) do |app| @caller = app.config[:caller] # <— OKAY TILL HERE print app.config[:caller] <— works here but still does not work inside later loops, @caller is nil in the later loops

    Basically, i wanted to be able to instantiate the program from another one, passing some parameters from previous one, which was easy in the old system without the App class. (the App class is inspired by the Shoes way).

    I was wondering whether the above issue might make sense to you immediately.

    Why am i losing the outer scope ?

    thanks and regards rahul


    November 17, 2010 at 9:21 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: