File: Menu.pm

package info (click to toggle)
libur-perl 0.470%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,192 kB
  • sloc: perl: 61,814; javascript: 255; xml: 108; sh: 13; makefile: 9
file content (33 lines) | stat: -rw-r--r-- 810 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package Vending::Command::Menu;
use strict;
use warnings;

class Vending::Command::Menu {
    is => ['UR::Object::Command::List', 'Vending::Command' ],
    doc => 'Show the items available to buy',
    has => [
        subject_class_name => { is_constant => 1, value => 'Vending::MachineLocation' },
        filter => { value => 'is_buyable=1' },
        show => { value => 'name,label,price' },
    ],
};

sub execute {
    my $self = shift;

    my $super = $self->super_can('_execute_body');
    $super->($self,@_);

#$DB::single=1;
    my $machine = $self->machine;
    my $inserted = $machine->coin_box->content_value();
    if ($inserted) {
        printf("You have inserted \$%.2f so far\n", $inserted/100);
    } else {
        print "You have not inserted any money yet\n";
    }
    return 1;

}
1;