Acme-Chef

 view release on metacpan or  search on metacpan

lib/Acme/Chef/Ingredient.pm  view on Meta::CPAN


package Acme::Chef::Ingredient;

use strict;
use warnings;

use Carp;

use vars qw/$VERSION %Measures %MeasureTypes/;
$VERSION = '1.00';

=head1 NAME

Acme::Chef::Ingredient - Internal module used by Acme::Chef

=head1 SYNOPSIS

  use Acme::Chef;

=head1 DESCRIPTION

Please see L<Acme::Chef>;

=head2 METHODS

This is a list of methods in the package.

=over 2

=cut


%Measures = (
  ''          => '',

  g           => 'dry',
  kg          => 'dry',
  pinch       => 'dry',
  pinches     => 'dry',
  ml          => 'liquid',
  l           => 'liquid',
  dash        => 'liquid',
  dashes      => 'liquid',
  cup         => '',
  cups        => '',
  teaspoon    => '',
  teaspoons   => '',
  tablespoon  => '',
  tablespoons => '',
);

%MeasureTypes = (
  heaped => 'dry',
  level  => 'dry',
);

=item new

Acme::Chef::Ingredient constructor. Takes key/value pairs as argument which
will be used as attributes. The following attributes are currently
required:

  name
  value
  measure
  measure_type

=cut

sub new {
   my $proto = shift;
   my $class = ref $proto || $proto;

   my $self = {};

   if ( ref $proto ) {
      %$self = %$proto;
   }

   my %args  = @_;

   %$self = (
     name         => '',
     value        => undef,
     measure      => '',
     measure_type => '',
     type         => '',
     %$self,
     %args,
   );

   bless $self => $class;

   $self->determine_type() if not $self->{type};

   return $self;
}


=item type

Returns the type of the Ingredient.

=cut

sub type {
   my $self = shift;

   $self->determine_type() if $self->{type} eq '';

   return $self->{type};
}

=item determine_type

Also returns the type if the Ingredient, but forces a fresh run of the
type inferer.

=cut

sub determine_type {



( run in 1.063 second using v1.01-cache-2.11-cpan-ceb78f64989 )