GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  OBJECT::ENUM (3)

.ds Aq ’

NAME

Object::Enum - replacement for "if ($foo eq bar)"

CONTENTS

SYNOPSIS



  use Object::Enum qw(Enum);

  my $color = Enum([ qw(red yellow green) ]);
  # ... later
  if ($color->is_red) {
  # it cant be yellow or green



EXPORTS

See Sub::Exporter for ways to customize this module’s exports.

    Enum

An optional shortcut for Object::Enum->new.

CLASS METHODS

    new



  my $obj = Object::Enum->new(\@values);
  # or
  $obj = Object::Enum->new(\%arg);



Return a new Object::Enum, with one or more sets of possible values.

The simplest case is to pass an arrayref, which returns an object capable of having any one of the given values or of being unset.

The more complex cases involve passing a hashref, which may have the following keys:
o unset

whether this object can be ’unset’ (defaults to true)

o default

this object’s default value is (defaults to undef)

o values

an arrayref, listing the object’s possible values (at least one required)

OBJECT METHODS

    spawn

    clone



  my $new = $obj->clone;

  my $new = $obj->clone($value);



Create a new Enum from an existing object, using the same arguments as were originally passed to new when that object was created.

An optional value may be passed in; this is identical to (but more convenient than) calling value with the same argument on the newly cloned object.

This method was formerly named spawn. That name will still work but is deprecated.

    value

The current value as a string (or undef)

Note: don’t pass in undef; use the unset method instead.

    values

The possible values for this object

    unset

Unset the object’s value (set to undef)

    is_*

    set_*

Automatically generated from the values passed into new.

None of these methods take any arguments.

The set_* methods are chainable; that is, they return the object on which they were called. This lets you do useful things like:



  use Object::Enum Enum => { -as => color, values => [qw(red blue)] };

  print color->set_red->value; # prints red



AUTHOR

Hans Dieter Pearcey, <hdp at cpan.org>

BUGS

Please report any bugs or feature requests to bug-object-enum at rt.cpan.org, or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Object-Enum>. I will be notified, and then you’ll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.



    perldoc Object::Enum



You can also look for information at:
o AnnoCPAN: Annotated CPAN documentation

<http://annocpan.org/dist/Object-Enum>

o CPAN Ratings

<http://cpanratings.perl.org/d/Object-Enum>

o RT: CPAN’s request tracker

<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Object-Enum>

o Search CPAN

<http://search.cpan.org/dist/Object-Enum>

o GitHub

<https://github.com/jmmills/object-enum/>

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2006 Hans Dieter Pearcey, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 OBJECT::ENUM (3) 2014-05-20

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.