Script errors

require ‘rubygems’
require ‘ruport’
require ‘ruport/util’
require ‘date’
require ‘optparse’

opts = OptionParser.new do |opts|
opts.on("-h", “–help”, “Displays this help.”) do |a|
puts opts
end
opts.on("-s", “–startdate”, “Determines what start date to use.”) do
|b|
@startdate = Date.new(*ParseDate.parsedate(b)[0,3])
end
opts.on("-e", “–enddate”, “Determines what end date to use.”) do |c|
@enddate = Date.new(*ParseDate.parsedate©[0,3])
end
opts.on("-o", “–output”, “Specify Output format: svg|pdf|jpg”) do |d|
if ARGV = svg
saveinput = GraphReport.generate{|r| r.save_as(“Reportgraph.svg”)}
elsif ARGV = pdf
#get pdf gem to output to pdf(ruport might have it included)
end
end
end

opts.parse!(ARGV)

result = (@startdate@enddate).to_a
range = result.size

class GraphReport < Ruport::Report
renders_as_graph

def generate

verizondat = []
qwestdat = []
level3dat = []
attdat = []
sprintdat = []
data = File.readlines(“data.csv”)
head = data[0]
verizondat = data.grep(/Verizon/)
qwestdat = data.grep(/Qwest/)
level3dat = data.grep(/Level3/)
attdat = data.grep(/AT&T/)
sprintdat = data.grep(/Sprint/)
csv = ([head] + data).join

table = Ruport::Data::Table.parse(csv)

graph = Ruport::Graph(:column_names => #the 15 graph points by average

graph.add_line verizondat.column(‘AVERAGE’).map{|x|
x.grep(/@startdate@enddate/).to_i}, :name=> “Verizon”
graph.add_line qwestdat.column(‘AVERAGE’).map{|x|
x.grep(/@startdate@enddate/).to_i}, :name=> “Qwest”
graph.add_line level3dat.column(‘AVERAGE’).map{|x|
x.grep(/@startdate@enddate/).to_i}, :name=> “Level3”
graph.add_line attdat.column(‘AVERAGE’).map{|x|
x.grep(/@startdate@enddate/).to_i}, :name=> “AT&T”
graph.add_line sprintdat.column(‘AVERAGE’).map{|x|
x.grep(/@startdate@enddate/).to_i}, :name=> “Sprint”
end
end

return graph

GraphReport.generate{|r| r.save_as(“graph.svg”)}

##############
OUTPUT:

ruby reportgraph.rb
reportgraph.rb:55: syntax error, unexpected tIDENTIFIER, expecting ‘)’
graph.add_line verizondat.column(‘AVERAGE’).map{|x|
x.grep(/@startdate@enddate/).to_i}, :name=> “Verizon”
^
reportgraph.rb:55: syntax error, unexpected ‘,’, expecting kEND
graph.add_line verizondat.column(‘AVERAGE’).map{|x|
x.grep(/@startdate@enddate/).to_i}, :name=> “Verizon”

###############

all the commented objects also need fixing if anyone wants to throw
suggestions at me while i work on it over the night.

Much thanks!

Hi,

At Tue, 4 Sep 2007 15:43:55 +0900,
Michael L. wrote in [ruby-talk:267464]:

graph = Ruport::Graph(:column_names => #the 15 graph points by average

The paren in this line doesn’t seem closed, and you may forget
qoutes?

Nobuyoshi N. wrote:

Hi,

At Tue, 4 Sep 2007 15:43:55 +0900,
Michael L. wrote in [ruby-talk:267464]:

graph = Ruport::Graph(:column_names => #the 15 graph points by average

The paren in this line doesn’t seem closed, and you may forget
qoutes?

lol thanks, now however i run upon a second error, line 29

result = (@startdate@enddate)

OUTPUTS:

reportgraph.rb:29: bad value for range (ArgumentError)

fun timez.
any ideas?

Thanks!

On 4 Sep 2007, at 17:42, Michael L. wrote:

fun timez.
any ideas?

Thanks!

What options did you call the script with? Whatever, your use of
OptionParser is wrong. You are asking for date options with no
arguments where you should be asking for arguments:

opts.on("-s", “–startdate”, “Determines what start date to use.”) do

Should be:

opts.on("-s", “–startdate DATE”, “Determines what start date to
use.”) do

And the same for the end date and output options. Check the
OptionParser docs. There are other bugs in there as well: “ARGV =
svg” should surely be “d = ‘svg’” for instance.

Alex G.

Bioinformatics Center
Kyoto University

Hi,

At Tue, 4 Sep 2007 17:42:45 +0900,
Michael L. wrote in [ruby-talk:267482]:

result = (@startdate@enddate)

OUTPUTS:

reportgraph.rb:29: bad value for range (ArgumentError)

Maybe, one of them (or both) is nil?

Alex G. wrote:

What options did you call the script with? Whatever, your use of
OptionParser is wrong. You are asking for date options with no
arguments where you should be asking for arguments:

opts.on("-s", “–startdate”, “Determines what start date to use.”) do

Should be:

opts.on("-s", “–startdate DATE”, “Determines what start date to
use.”) do

And the same for the end date and output options. Check the
OptionParser docs. There are other bugs in there as well: “ARGV =
svg” should surely be “d = ‘svg’” for instance.

well after fixing those few flaws i get a huge nomethoderror from the
method .column such as verizondat.column …understandable because it
is actually supposed to use table.column but in fact table is tied to

table = Ruport::Data::Table.parse(csv)

which parses the data, not the grep’d array…so i guess my question now
would be how do i perform the same function except on the grep’d data?

-Thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs