Gnuplot-Builder

 view release on metacpan or  search on metacpan

lib/Gnuplot/Builder/Dataset.pm  view on Meta::CPAN

package Gnuplot::Builder::Dataset;
use strict;
use warnings;
use Gnuplot::Builder::PrototypedData;
use Scalar::Util qw(weaken blessed);
use Carp;
use overload '""' => 'to_string';

sub new {
    my ($class, $source, @set_option_args) = @_;
    my $self = bless {
        pdata => undef,
        pdata_join => undef,  ## deprecated. should be removed in the future.
        parent => undef,
    }, $class;

lib/Gnuplot/Builder/Dataset.pm  view on Meta::CPAN

    return $class->new->set_file($filename)->set_option(@set_option_args);
}

sub new_data {
    my ($class, $data_provider, @set_option_args) = @_;
    return $class->new->set_file('-')->set_data($data_provider)->set_option(@set_option_args);
}

sub _init_pdata {
    my ($self) = @_;
    weaken $self;
    $self->{pdata} = Gnuplot::Builder::PrototypedData->new(
        entry_evaluator => sub {
            my ($key, $coderef) = @_;
            return $coderef->($self, $key);
        },
        attribute_evaluator => { source => sub {
            my ($key, $coderef) = @_;
            return $coderef->($self);
        } },
    );

lib/Gnuplot/Builder/Script.pm  view on Meta::CPAN

package Gnuplot::Builder::Script;
use strict;
use warnings;
use Gnuplot::Builder::PrototypedData;
use Gnuplot::Builder::Util qw(quote_gnuplot_str);
use Gnuplot::Builder::Process;
use Scalar::Util qw(weaken blessed refaddr);
use Carp;
use overload '""' => "to_string";

sub new {
    my ($class, @set_args) = @_;
    my $self = bless {
        pdata => undef,
        parent => undef,
    };
    $self->_init_pdata();
    if(@set_args) {
        $self->set(@set_args);
    }
    return $self;
}

sub _init_pdata {
    my ($self) = @_;
    weaken $self;
    $self->{pdata} = Gnuplot::Builder::PrototypedData->new(
        entry_evaluator => sub {
            my ($key, $value_code) = @_;
            if(defined($key)) {
                return $value_code->($self, substr($key, 1));
            }else {
                return $value_code->($self);
            }
        }
    );



( run in 0.445 second using v1.01-cache-2.11-cpan-1f129e94a17 )