Forum: Ruby Ruport, Table append, access to record

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C0f4cef363d69500730aa9afa9cf7774?d=identicon&s=25 unknown (Guest)
on 2007-02-25 20:05
(Received via mailing list)
I'm looping through an Excel spreadsheeet, acquiring cells, and adding
the data to a ruport table.  I want access to the record just
appended, but unsure of how to get to it.  Code follows:

         begin
            @tbl_PAS << {  # append row into table
                :clientid =>
get_cell_as_text(row,@buildlist[:clientid]),
                :wdatetime =>
get_cell_as_date(row,@buildlist[:wdatetime]),
                :emp => emp_merge(row),
                :whours => get_cell_as_num(row,@buildlist[:whours]),
...
            }
         rescue
            puts "Unexpected error inserting data into table."
            puts options.inspect
            raise
         end

         # tag record for summary counts
         case
         when r.proj[0,4] == 'ADMN'
            r.tag(:Administration)
         when r.task[0,5] == 'AL916'
            t.tag(:Support)
...

I want r. to the last record appended.  I was hoping r = @tbl_PAS <<
would be it.  But r points to the table, not the last record appended.

Any advice?
dvn
C0f4cef363d69500730aa9afa9cf7774?d=identicon&s=25 unknown (Guest)
on 2007-02-25 20:31
(Received via mailing list)
I've attempted the following, but it is not buying it.  I get a tassoc
error?

            r = Ruport::Data::Record.new {
                :clientid =>
get_cell_as_text(row,@buildlist[:clientid]),
                :wdatetime =>
get_cell_as_date(row,@buildlist[:wdatetime]),
                :emp => emp_merge(row),
                :whours => get_cell_as_num(row,@buildlist[:whours]),
...
            }
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2007-02-25 20:38
(Received via mailing list)
On 2/25/07, donn@cmscms.com <donn@cmscms.com> wrote:

> I want r. to the last record appended.  I was hoping r = @tbl_PAS <<
> would be it.  But r points to the table, not the last record appended.

try:

r = @tbl_PAS[-1]

This should do the trick.

For further questions, please come catch up with us on the Ruport list.
http://list.rubyreports.org

-greg
C0f4cef363d69500730aa9afa9cf7774?d=identicon&s=25 unknown (Guest)
on 2007-02-26 00:46
(Received via mailing list)
On Feb 25, 1:37 pm, "Gregory Brown" <gregory.t.br...@gmail.com> wrote:
>
> For further questions, please come catch up with us on the Ruport 
list.http://list.rubyreports.org
>
> -greg

Thanks.  Sometimes "too easy" makes one feel really dumb.  I'm trying
to exploit all the capabilities of Ruport's tabling handling -- and
struggling.  I don't know why this is seeming so difficult.  I now get
an error when using group_by_tag.  In my data load, I've done the
following:

   def apply_category(r)
      case
      when r.proj[0,4] == 'ADMN'
         r.tag(:Administration)
      when r.task[0,5] == 'AL916'
         r.tag(:Support)
      when (r.task[0,2] == 'IS' or
            r.proj == '76011' or
            r.proj == '75634' or
            r.proj == '75638')
         r.tag(:Development)
      else
         r.tag(:Other)
      end
   end

When I attempt to utilize those tags, things go south.  I've
attempted:

   def cat_hours(c)
      hrs = 0
      t = @tbl_PAS.group_by_tag(c)
      #@tbl_PAS.group_by_tag(:Development).each {|r| hrs += r.whours}
      printf "%-15s = %5.2f\n",c,hrs
   end

But I am typically greeted with "Exception: undefined method
`group_by_tag' for #<Ruport::Data::Table:0x2d6c700>"

If you have any suggestions, that would be much appreciated.  What I
am doing is attempting to deal with the increased time reporting
demands of my company.  Their time tracking system is dismal, but it
exports data to Excel.  So I want to table everything, categorize it
at will, and produce six or seven different summaries from the various
data elements available.

thanks again,
dvn
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2007-02-26 01:00
(Received via mailing list)
On Feb 25, 2007, at 5:45 PM, donn@cmscms.com wrote:

> On Feb 25, 1:37 pm, "Gregory Brown" <gregory.t.br...@gmail.com> wrote:
>> For further questions, please come catch up with us on the Ruport
>> list.http://list.rubyreports.org

> I'm trying to exploit all the capabilities of Ruport's tabling
> handling -- and struggling.

You might really want to consider taking Greg's advice then and
asking the Ruport list directly.  I don't say that to be mean, I'm
just betting the people there are much more likely to know the exact
answers to your questions.  (I don't sadly, or I would answer them.)

I know Greg tries to keep one eye on Ruby Talk, but I'm sure he
misses some things.  He sees every single message on the Ruport list
though, as do numerous other experienced Ruport users.

The list is a Google Group, so you can interact with it completely
from their web interface and not have to hassle with more email
messages.  I always find that nice when I just want to ask a few
questions.

Anyway, just a thought.  Good luck with your report.

James Edward Gray II
This topic is locked and can not be replied to.