Protocol::XMLRPC::Value::Integer - XML-RPC array


Protocol-XMLRPC documentation Contained in the Protocol-XMLRPC distribution.

Index


Code Index:

NAME

Top

Protocol::XMLRPC::Value::Integer - XML-RPC array

SYNOPSIS

Top

    my $integer = Protocol::XMLRPC::Value::Integer->new(123);

DESCRIPTION

Top

XML-RPC integer

ATTRIBUTES

Top

alias

XML-RPC integer can be represented as 'int' and 'i4'. This parameter is 'i4' by default, but you can change it to 'int'.

METHODS

Top

new

Creates new Protocol::XMLRPC::Value::Integer instance.

type

Returns 'integer'.

value

    my $integer = Protocol::XMLRPC::Value::Integer->new(1);
    # $integer->value returns 1

Returns serialized Perl5 scalar.

to_string

    my $integer = Protocol::XMLRPC::Value::Integer->new(1);
    # $integer->to_string is now '<i4>1</i4>'

    my $integer = Protocol::XMLRPC::Value::Integer->new(1, alias => 'int');
    # $integer->to_string is now '<int>1</int>'

XML-RPC integer string representation.

AUTHOR

Top

Viacheslav Tykhanovskyi, vti@cpan.org.

COPYRIGHT

Top


Protocol-XMLRPC documentation Contained in the Protocol-XMLRPC distribution.

package Protocol::XMLRPC::Value::Integer;

use strict;
use warnings;

use base 'Protocol::XMLRPC::Value';

sub new {
    my $self = shift->SUPER::new(@_);

    $self->{alias} ||= 'i4';

    return $self;
}

sub alias { defined $_[1] ? $_[0]->{alias} = $_[1] : $_[0]->{alias} }

sub type {'int'}

sub to_string {
    my $self = shift;

    my $value = $self->value;

    $value = int($value);

    my $alias = $self->alias;
    return "<$alias>$value</$alias>";
}

1;
__END__