Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6174507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:45:55+00:00 2026-05-23T23:45:55+00:00

I am defining a bunch of class variables in my Ruby class and initializing

  • 0

I am defining a bunch of class variables in my Ruby class and initializing them to a value, but when I print them in my to_url function they are all null, can someone tell me why???

class BarChart < GoogleChart
    @axes_prefix       = "chxt="
    @data_scale_prefix = "chds="
    @type              = "#@@type_prefix" + "bvg"
    @size              = "#@@size_prefix" + "800x375"
    @colors            = "#@@color_prefix" + "4466AA"
    @axes              = "#@axes_prefix" + "x,y,x,y"
    @x_axis_index      = "0"
    @y_axis_index      = "1"
    @x_axis_label_index  = "2"
    @y_axis_label_index  = "3"
    @axes_label_position_prefix = "chxp="
    @axis_range_prefix          = "chxr="

    def initialize(title, data, labels, x_axis_label, y_axis_label)
        @title, @data, @labels, @x_axis_label, @y_axis_label = 
            title, data, labels, x_axis_label, y_axis_label
        super(@title, @type, @size)
        to_url()
    end


    def to_url()
        puts @axes_prefix, @data_scale_prefix, @type, @size, @colors, 
        @axes, @x_axis_label_index, @y_axis_label_index, @x_axis_index, @y_axis_index
    end


    def start()
    b = BarChart.new("CHART", "0,1,2,3,4,5,6,7,8,9", 
    "ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE", 
    "Zero to Nine", "Numbers").to_s()
    end

if __FILE__ == $0
    start()
end

Any ideas would be great.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:45:56+00:00Added an answer on May 23, 2026 at 11:45 pm
    1. It’s not a class variables, it’s a instance variables. (@@foo – it’s class variable)
    2. You can’t initialize them outside of the methods. Move them to the initialize method, for example.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Defining custom components in Facelets is easy and quick but there's one thing I
When defining a method on a class in Python, it looks something like this:
; defining stream-for-each (define (stream-for-each proc s) (if (stream-null? s) 'done (begin (proc (stream-car
I have some expensive function f(x) that I want to only calculate once, but
Defining a function, MyFunction(argument, *args): [do something to argument[arg] for arg in *args] if
When defining class attributes through calculated names, as in: class C(object): for name in
When defining a COM-visible class in C++ I can define the supported threading model
ORIGINAL POST: I'm probably defining my route incorrectly but I'm following along with this
Defining my boost::graph like the following, I get edge indices zero for all edges.
When defining the list_display array for a ModelAdmin class, if a BooleanField or NullBooleanField

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.