0
我定義了一堆類變量在我的Ruby類,並將其初始化爲一個值,但是當我打印出來,我to_url
功能他們都爲空,誰能告訴我,爲什麼???Ruby類變量是空
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
任何想法都會很棒。
謝謝。
啊我明白了,我有兩個混合起來 –