« Karabiner/Manipulator/Conditions/Device_if.pm
↑ Summary
Karabiner/Manipulator/Actions/To_delayed_if_canceled.pm »
| 1 | package JSON::Karabiner::Manipulator::Conditions::Keyboard_type_if ; | ||
| 2 | $JSON::Karabiner::Manipulator::Conditions::Keyboard_type_if::VERSION = '0.008'; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use JSON; | ||
| 6 | use Carp; | ||
| 7 | use parent 'JSON::Karabiner::Manipulator::Conditions'; | ||
| 8 | |||
| 9 | sub new { | ||
| 10 | my $class = shift; | ||
| 11 | my ($type, $value) = @_; | ||
| 12 | my $obj = $class->SUPER::new($type, $value); | ||
| 13 | $obj->{data} = $value || {}, | ||
| 14 | return $obj; | ||
| 15 | } | ||
| 16 | |||
| 17 | sub add_keyboard_types { | ||
| 18 | my $s = shift; | ||
| 19 | my @values = @_; | ||
| 20 | croak 'A list of keyboard types is required' unless @values; | ||
| 21 | $s->{data}{keyboard_types} = \@values ; | ||
| 22 | } | ||
| 23 | |||
| 24 | sub add_description { | ||
| 25 | my $s = shift; | ||
| 26 | my $desc = shift; | ||
| 27 | croak ('No description passed.') unless $desc; | ||
| 28 | $s->{data}{description} = $desc; | ||
| 29 | |||
| 30 | } | ||
| 31 | |||
| 32 | sub TO_JSON { | ||
| 33 | my $obj = shift; | ||
| 34 | use Data::Dumper qw(Dumper); | ||
| 35 | my $name = $obj->{def_name}; | ||
| 36 | my $value = $obj->{data}; | ||
| 37 | print Dumper $value; | ||
| 38 | my %super_hash = (%$value, type => $name); | ||
| 39 | return { %super_hash }; | ||
| 40 | |||
| 41 | } | ||
| 42 | #ABSTRACT: definition for keyboard_type_if condition | ||
| 43 | |||
| 44 | 1; | ||
| 45 | |||
| 46 | __END__ |