Socialtext::WikiObject::TableConfig - Extract a table into a hash


Socialtext-Resting-Utils documentation Contained in the Socialtext-Resting-Utils distribution.

Index


Code Index:

NAME

Top

Socialtext::WikiObject::TableConfig - Extract a table into a hash

METHODS

Top

table

Return a hashref to the parsed table.

AUTHOR

Top

Luke Closs, <luke.closs at socialtext.com>

BUGS

Top

Please report any bugs or feature requests to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Socialtext-Resting-Utils. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Top


Socialtext-Resting-Utils documentation Contained in the Socialtext-Resting-Utils distribution.
package Socialtext::WikiObject::TableConfig;
use strict;
use warnings;
use base 'Socialtext::WikiObject';

our $VERSION = '0.01';

sub table {
    my $self = shift;

    my $table = $self->{table} or die "Can't find a table on the page!\n";
    if ($table->[0][0] =~ m/^\*.+\*$/) {
        shift @$table; # remove the table header
    }

    my %results;
    for my $r (@$table) {
        $results{$r->[0]} = $r->[1];
    }

    return \%results;
}

1;