| Chart-OFC documentation | Contained in the Chart-OFC distribution. |
Chart::OFC::Role::OFCDataLines - helper for classes which generate OFC data
version 0.10
package Chart::OFC; use MooseX::StrictConstructor; with 'Chart::OFC::Role::OFCDataLines';
This class provides a common helper method for classes which generate OFC data (which is most classes in the Chart::OFC distro).
Dave Rolsky <autarch@urth.org>
This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
| Chart-OFC documentation | Contained in the Chart-OFC distribution. |
package Chart::OFC::Role::OFCDataLines; BEGIN { $Chart::OFC::Role::OFCDataLines::VERSION = '0.10'; } use strict; use warnings; use Moose::Role; requires '_ofc_data_lines'; sub _data_line ## no critic RequireArgUnpacking { my $self = shift; my $label = shift; my @vals = @_; $label =~ s/color/colour/; my $line = q{&} . $label . q{=}; $line .= join ',', map { $self->_format_value($_) } @vals; $line .= q{&}; return $line; } sub _format_value { my $self = shift; my $value = shift; return 'null' unless defined $value; # nested array ref values attr for things like scatter charts if ( ref $value eq 'ARRAY' ) { return '[' . ( join ',', @{ $value } ) . ']'; } else { return $self->_escape($value); } } sub _escape { shift; my $string = shift; $string =~ s/,/#comma#/g; return $string; } no Moose::Role; 1; # ABSTRACT: helper for classes which generate OFC data
__END__