blib/lib/Venus/Hash.pm

filter: Statementstmt 96.5% 193 / 200 Branchbran 66.6% 60 / 90 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 83.3% 35 / 42 Podpod 96.5% 28 / 29 totaltotal 85.9% 319 / 371 SCAR 41.5
CC
56
Cov
86%
puts
7.1
find
6.6
all
6.4
CRAP 63.7
« blib/lib/Venus/Meta.pm ↑ Summary blib/lib/Venus/Space.pm »
1 package Venus::Hash;
2  
3 16 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 ▶use Venus::Class 'base', 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 16 base 'Venus::Kind::Value';
11  
12 16 with 'Venus::Role::Mappable';
13  
14 # BUILDERS
15  
16 sub build_args {
17 371 ▶ my ($self, $data) = @_;
Subroutine build_args: called CC=3 SCAR=12.0
Pod undocumented
18  
19 371 ▶ if (keys %$data == 1 && exists $data->{value}) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::keys %$data == 1 and exists $data->{"value"}) 0 371 371
Condition66%2/3
CORE::keys %$data == 1 and exists $data->{"value"}
!ll&&!rl&&r
319520
MC/DC0%0/2
CORE::keys %$data == 1 and exists $data->{"value"}
CORE::keys %$data == 1 exists $data->{"value"}
Truth table66%2/3
A and B
A= CORE::keys %$data == 1B= exists $data->{"value"}
ABresult
0X0
100
111
20 0 return $data;
21 }
22 return {
23 371 value => $data
24 };
25 }
26  
27 # METHODS
28  
29 sub all {
30 2 ▶ my ($self, $code) = @_;
Subroutine all: called CC=6 SCAR=18.6
Pod documented
31  
32 2 my $data = $self->get;
33  
34 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
35  
36 2 my $failed = 0;
37  
38 2 for my $index (CORE::keys %$data) {
39 8 my $value = $data->{$index};
40  
41 8 local $_ = $value;
42 8 ▶ $failed++ if !$code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
unless &$code($index, $value) 0 8 8
43  
44 8 ▶ CORE::last if $failed;
Branch: 1 branch
BranchTrueFalseTotal
if $failed 0 8 8
45 }
46  
47 2 ▶ return $failed ? false : true;
Branch: 1 branch
BranchTrueFalseTotal
$failed ? : 0 2 2
48 }
49  
50 sub any {
51 2 ▶ my ($self, $code) = @_;
Subroutine any: called CC=6 SCAR=18.6
Pod documented
52  
53 2 my $data = $self->get;
54  
55 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
56  
57 2 my $found = 0;
58  
59 2 for my $index (CORE::keys %$data) {
60 8 my $value = $data->{$index};
61  
62 8 local $_ = $value;
63 8 ▶ $found++ if $code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
if &$code($index, $value) 0 8 8
64  
65 8 ▶ CORE::last if $found;
Branch: 1 branch
BranchTrueFalseTotal
if $found 0 8 8
66 }
67  
68 2 ▶ return $found ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$found ? : 0 2 2
69 }
70  
71 sub call {
72 2 ▶ my ($self, $mapper, $method, @args) = @_;
Subroutine call: called CC=1 SCAR=0.0
Pod documented
73  
74 2 require Venus::Type;
75  
76 return $self->$mapper(sub{
77 8 ▶ my ($key, $val) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
78  
79 8 my $type = Venus::Type->new($val)->deduce;
80  
81 8 local $_ = $type;
82  
83 8 $key, $type->$method(@args)
84 2 });
85 }
86  
87 sub count {
88 3 ▶ my ($self) = @_;
Subroutine count: called CC=1 SCAR=0.0
Pod documented
89  
90 3 my $data = $self->get;
91  
92 3 return scalar(CORE::keys(%$data));
93 }
94  
95 sub default {
96 1 ▶ return {};
Subroutine default: called CC=1 SCAR=0.0
Pod documented
97 }
98  
99 sub delete {
100 1 ▶ my ($self, $key) = @_;
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
101  
102 1 my $data = $self->get;
103  
104 1 return CORE::delete($data->{$key});
105 }
106  
107 sub each {
108 2 ▶ my ($self, $code) = @_;
Subroutine each: called CC=4 SCAR=14.0
Pod documented
109  
110 2 my $data = $self->get;
111  
112 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
113  
114 2 my $results = [];
115  
116 2 for my $index (CORE::sort(CORE::keys(%$data))) {
117 8 my $value = $data->{$index};
118  
119 8 local $_ = $value;
120 8 CORE::push(@$results, $code->($index, $value));
121 }
122  
123 2 ▶ return wantarray ? (@$results) : $results;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
124 }
125  
126 sub empty {
127 1 ▶ my ($self) = @_;
Subroutine empty: called CC=1 SCAR=0.0
Pod documented
128  
129 1 my $data = $self->get;
130  
131 1 CORE::delete(@$data{CORE::keys(%$data)});
132  
133 1 return $data;
134 }
135  
136 sub exists {
137 2 ▶ my ($self, $key) = @_;
Subroutine exists: called CC=2 SCAR=6.9
Pod documented
138  
139 2 my $data = $self->get;
140  
141 2 ▶ return CORE::exists($data->{$key}) ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
exists $data->{$key} ? : 1 1 2
142 }
143  
144 sub find {
145 85 ▶ my ($self, @args) = @_;
Subroutine find: called CC=6 SCAR=18.9
Pod documented
146  
147 85 my $seen = 0;
148 85 my $item = my $data = $self->get;
149  
150 85 ▶ for (my $i = 0; $i < @args; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @args) 128 85 213
151 128 ▶ if (ref($item) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $item eq 'ARRAY') { } 6 122 128
elsif (ref $item eq 'HASH') { } 122 0 122
152 6 ▶ if ($args[$i] !~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args[$i] =~ /^\d+$/u) 0 6 6
153 0 $item = undef;
154 0 $seen = 0;
155 0 CORE::last;
156 }
157 6 $seen = $args[$i] <= $#{$item};
158 6 $item = $item->[$args[$i]];
159 }
160 elsif (ref($item) eq 'HASH') {
161 122 $seen = exists $item->{$args[$i]};
162 122 $item = $item->{$args[$i]};
163 }
164 else {
165 0 $item = undef;
166 0 $seen = 0;
167 }
168 }
169  
170 85 ▶ return wantarray ? ($item, int(!!$seen)) : $item;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 7 78 85
171 }
172  
173 sub get {
174 318 ▶ my ($self, @args) = @_;
Subroutine get: called CC=2 SCAR=6.9
Pod documented
175  
176 318 ▶ return $self->value if !@args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 314 4 318
177  
178 4 my ($index) = @args;
179  
180 4 return $self->value->{$index};
181 }
182  
183 sub grep {
184 3 ▶ my ($self, $code) = @_;
Subroutine grep: called CC=5 SCAR=16.2
Pod documented
185  
186 3 my $data = $self->get;
187  
188 3 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 3 3
189  
190 3 my $result = [];
191  
192 3 for my $index (CORE::sort(CORE::keys(%$data))) {
193 12 my $value = $data->{$index};
194  
195 12 local $_ = $value;
196 12 ▶ CORE::push(@$result, $index, $value) if $code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
if &$code($index, $value) 8 4 12
197 }
198  
199 3 ▶ return wantarray ? (@$result) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 3 3
200 }
201  
202 sub iterator {
203 2 ▶ my ($self) = @_;
Subroutine iterator: called CC=1 SCAR=0.0
Pod documented
204  
205 2 my $data = $self->get;
206 2 my @keys = CORE::sort(CORE::keys(%{$data}));
207  
208 2 my $i = 0;
209 2 my $j = 0;
210  
211 return sub {
212 10 ▶ return undef if $i > $#keys;
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
if $i > $#keys 2 8 10
213 8 ▶ return wantarray ? ($keys[$j++], $data->{$keys[$i++]}) : $data->{$keys[$i++]};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 4 8
214 }
215 2 }
216  
217 sub keys {
218 1 ▶ my ($self) = @_;
Subroutine keys: called CC=1 SCAR=0.0
Pod documented
219  
220 1 my $data = $self->get;
221  
222 1 return [CORE::sort(CORE::keys(%$data))];
223 }
224  
225 sub length {
226 1 ▶ my ($self) = @_;
Subroutine length: called CC=1 SCAR=0.0
Pod documented
227  
228 1 return $self->count;
229 }
230  
231 sub list {
232 2 ▶ my ($self) = @_;
Subroutine list: called CC=2 SCAR=6.9
Pod documented
233  
234 2 ▶ return wantarray ? (%{$self->value}) : scalar(CORE::keys(%{$self->value}));
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
235 }
236  
237 sub map {
238 3 ▶ my ($self, $code) = @_;
Subroutine map: called CC=4 SCAR=14.0
Pod documented
239  
240 3 my $data = $self->get;
241  
242 3 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 3 3
243  
244 3 my $result = [];
245  
246 3 for my $index (CORE::sort(CORE::keys(%$data))) {
247 12 my $value = $data->{$index};
248  
249 12 local $_ = $value;
250 12 CORE::push(@$result, ($code->($index, $value)));
251 }
252  
253 3 ▶ return wantarray ? (@$result) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 3 3
254 }
255  
256 sub merge {
257 24 ▶ my ($self, @rvalues) = @_;
Subroutine merge: called CC=1 SCAR=0.0
Pod documented
258  
259 24 require Venus;
260  
261 24 my $lvalue = {%{$self->get}};
262  
263 24 return Venus::merge($lvalue, @rvalues);
264 }
265  
266 sub none {
267 2 ▶ my ($self, $code) = @_;
Subroutine none: called CC=6 SCAR=18.6
Pod documented
268  
269 2 my $data = $self->get;
270  
271 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
272  
273 2 my $found = 0;
274  
275 2 for my $index (CORE::sort(CORE::keys(%$data))) {
276 8 my $value = $data->{$index};
277  
278 8 local $_ = $value;
279 8 ▶ $found++ if $code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
if &$code($index, $value) 0 8 8
280  
281 8 ▶ CORE::last if $found;
Branch: 1 branch
BranchTrueFalseTotal
if $found 0 8 8
282 }
283  
284 2 ▶ return $found ? false : true;
Branch: 1 branch
BranchTrueFalseTotal
$found ? : 0 2 2
285 }
286  
287 sub one {
288 2 ▶ my ($self, $code) = @_;
Subroutine one: called CC=6 SCAR=18.2
Pod documented
289  
290 2 my $data = $self->get;
291  
292 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
293  
294 2 my $found = 0;
295  
296 2 for my $index (CORE::sort(CORE::keys(%$data))) {
297 8 my $value = $data->{$index};
298  
299 8 local $_ = $value;
300 8 ▶ $found++ if $code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
if &$code($index, $value) 2 6 8
301  
302 8 ▶ CORE::last if $found > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $found > 1 0 8 8
303 }
304  
305 2 ▶ return $found == 1 ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$found == 1 ? : 2 0 2
306 }
307  
308 sub pairs {
309 1 ▶ my ($self) = @_;
Subroutine pairs: called CC=2 SCAR=7.0
Pod documented
310  
311 1 my $data = $self->get;
312  
313 1 my $result = [CORE::map { [$_, $data->{$_}] } CORE::sort(CORE::keys(%$data))];
314  
315 1 ▶ return wantarray ? (@$result) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
316 }
317  
318 sub path {
319 81 ▶ my ($self, $path) = @_;
Subroutine path: called CC=2 SCAR=6.9
Pod documented
320  
321 81 my @path = CORE::grep(/./, CORE::split(/\W/, $path));
322  
323 81 ▶ return wantarray ? ($self->find(@path)) : $self->find(@path);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 6 75 81
324 }
325  
326 sub puts {
327 4 ▶ my ($self, @args) = @_;
Subroutine puts: called CC=7 SCAR=19.5
Pod documented
328  
329 4 my $result = [];
330  
331 4 require Venus::Array;
332  
333 4 ▶ for (my $i = 0; $i < @args; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @args) 13 4 17
334 13 my ($into, $path) = @args[$i, $i+1];
335  
336 13 ▶ next if !defined $path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path 0 13 13
337  
338 13 my $value;
339 my @range;
340  
341 13 ▶ ($path, @range) = @{$path} if ref $path eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $path eq "ARRAY" 1 12 13
342  
343 13 $value = $self->path($path);
344 13 ▶ $value = Venus::Array->new($value)->range(@range) if ref $value eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "ARRAY" 1 12 13
345  
346 13 ▶ if (ref $into eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $into eq "SCALAR") 11 2 13
347 11 $$into = $value;
348 }
349  
350 13 CORE::push @{$result}, $value;
351 }
352  
353 4 ▶ return wantarray ? (@{$result}) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 4 4
354 }
355  
356 sub random {
357 1 ▶ my ($self) = @_;
Subroutine random: called CC=1 SCAR=0.0
Pod documented
358  
359 1 my $data = $self->get;
360 1 my $keys = [CORE::keys(%$data)];
361  
362 1 return $data->{@$keys[rand($#{$keys}+1)]};
363 }
364  
365 sub reset {
366 1 ▶ my ($self) = @_;
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
367  
368 1 my $data = $self->get;
369  
370 1 @$data{CORE::keys(%$data)} = ();
371  
372 1 return $data;
373 }
374  
375 sub reverse {
376 1 ▶ my ($self) = @_;
Subroutine reverse: called CC=2 SCAR=6.9
Pod documented
377  
378 1 my $data = $self->get;
379  
380 1 my $result = {};
381  
382 1 for (CORE::grep(CORE::defined($data->{$_}), CORE::sort(CORE::keys(%$data)))) {
383 4 $result->{$_} = $data->{$_};
384 }
385  
386 1 return {CORE::reverse(%$result)};
387 }
388  
389 sub set {
390 15 ▶ my ($self, @args) = @_;
Subroutine set: called CC=5 SCAR=17.8
Pod documented
391  
392 15 ▶ return $self->value if !@args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 15 15
393  
394 15 ▶ return $self->value(@args) if @args == 1 && ref $args[0] eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if @args == 1 and ref $args[0] eq "HASH" 0 15 15
Condition33%1/3
@args == 1 and ref $args[0] eq "HASH"
!ll&&!rl&&r
1500
MC/DC0%0/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1 ref $args[0] eq "HASH"
Truth table33%1/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
ABresult
0X0
100
111
395  
396 15 my ($index, $value) = @args;
397  
398 15 ▶ return if not defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 15 15
399  
400 15 return $self->value->{$index} = $value;
401 }
402  
403 sub slice {
404 1 ▶ my ($self, @args) = @_;
Subroutine slice: called CC=1 SCAR=0.0
Pod documented
405  
406 1 my $data = $self->get;
407  
408 1 return [@{$data}{@args}];
409 }
410  
411 16 1;
412  
413  
414  
415 =head1 NAME
416  
417 Venus::Hash - Hash Class
418  
419 =cut
420  
421 =head1 ABSTRACT
422  
423 Hash Class for Perl 5
424  
425 =cut
426  
427 =head1 SYNOPSIS
428  
429 package main;
430  
431 use Venus::Hash;
432  
433 my $hash = Venus::Hash->new({1..8});
434  
435 # $hash->random;
436  
437 =cut
438  
439 =head1 DESCRIPTION
440  
441 This package provides methods for manipulating hash data.
442  
443 =cut
444  
445 =head1 INHERITS
446  
447 This package inherits behaviors from:
448  
449 L<Venus::Kind::Value>
450  
451 =cut
452  
453 =head1 INTEGRATES
454  
455 This package integrates behaviors from:
456  
457 L<Venus::Role::Mappable>
458  
459 =cut
460  
461 =head1 METHODS
462  
463 This package provides the following methods:
464  
465 =cut
466  
467 =head2 all
468  
469 all(coderef $code) (boolean)
470  
471 The all method returns true if the callback returns true for all of the
472 elements.
473  
474 I<Since C<0.01>>
475  
476 =over 4
477  
478 =item all example 1
479  
480 # given: synopsis;
481  
482 my $all = $hash->all(sub {
483 $_ > 1
484 });
485  
486 # 1
487  
488 =back
489  
490 =over 4
491  
492 =item all example 2
493  
494 # given: synopsis;
495  
496 my $all = $hash->all(sub {
497 my ($key, $value) = @_;
498  
499 $value > 1
500 });
501  
502 # 1
503  
504 =back
505  
506 =cut
507  
508 =head2 any
509  
510 any(coderef $code) (boolean)
511  
512 The any method returns true if the callback returns true for any of the
513 elements.
514  
515 I<Since C<0.01>>
516  
517 =over 4
518  
519 =item any example 1
520  
521 # given: synopsis;
522  
523 my $any = $hash->any(sub {
524 $_ < 1
525 });
526  
527 # 0
528  
529 =back
530  
531 =over 4
532  
533 =item any example 2
534  
535 # given: synopsis;
536  
537 my $any = $hash->any(sub {
538 my ($key, $value) = @_;
539  
540 $value < 1
541 });
542  
543 # 0
544  
545 =back
546  
547 =cut
548  
549 =head2 call
550  
551 call(string $iterable, string $method) (any)
552  
553 The call method executes the given method (named using the first argument)
554 which performs an iteration (i.e. takes a callback) and calls the method (named
555 using the second argument) on the object (or value) and returns the result of
556 the iterable method.
557  
558 I<Since C<1.02>>
559  
560 =over 4
561  
562 =item call example 1
563  
564 # given: synopsis
565  
566 package main;
567  
568 my $call = $hash->call('map', 'incr');
569  
570 # ['1', 3, '3', 5, '5', 7, '7', 9]
571  
572 =back
573  
574 =over 4
575  
576 =item call example 2
577  
578 # given: synopsis
579  
580 package main;
581  
582 my $call = $hash->call('grep', 'gt', 4);
583  
584 # [5..8]
585  
586 =back
587  
588 =cut
589  
590 =head2 cast
591  
592 cast(string $kind) (object | undef)
593  
594 The cast method converts L<"value"|Venus::Kind::Value> objects between
595 different I<"value"> object types, based on the name of the type provided. This
596 method will return C<undef> if the invocant is not a L<Venus::Kind::Value>.
597  
598 I<Since C<0.08>>
599  
600 =over 4
601  
602 =item cast example 1
603  
604 package main;
605  
606 use Venus::Hash;
607  
608 my $hash = Venus::Hash->new;
609  
610 my $cast = $hash->cast('array');
611  
612 # bless({ value => [{}] }, "Venus::Array")
613  
614 =back
615  
616 =over 4
617  
618 =item cast example 2
619  
620 package main;
621  
622 use Venus::Hash;
623  
624 my $hash = Venus::Hash->new;
625  
626 my $cast = $hash->cast('boolean');
627  
628 # bless({ value => 1 }, "Venus::Boolean")
629  
630 =back
631  
632 =over 4
633  
634 =item cast example 3
635  
636 package main;
637  
638 use Venus::Hash;
639  
640 my $hash = Venus::Hash->new;
641  
642 my $cast = $hash->cast('code');
643  
644 # bless({ value => sub { ... } }, "Venus::Code")
645  
646 =back
647  
648 =over 4
649  
650 =item cast example 4
651  
652 package main;
653  
654 use Venus::Hash;
655  
656 my $hash = Venus::Hash->new;
657  
658 my $cast = $hash->cast('float');
659  
660 # bless({ value => "1.0" }, "Venus::Float")
661  
662 =back
663  
664 =over 4
665  
666 =item cast example 5
667  
668 package main;
669  
670 use Venus::Hash;
671  
672 my $hash = Venus::Hash->new;
673  
674 my $cast = $hash->cast('hash');
675  
676 # bless({ value => {} }, "Venus::Hash")
677  
678 =back
679  
680 =over 4
681  
682 =item cast example 6
683  
684 package main;
685  
686 use Venus::Hash;
687  
688 my $hash = Venus::Hash->new;
689  
690 my $cast = $hash->cast('number');
691  
692 # bless({ value => 2 }, "Venus::Number")
693  
694 =back
695  
696 =over 4
697  
698 =item cast example 7
699  
700 package main;
701  
702 use Venus::Hash;
703  
704 my $hash = Venus::Hash->new;
705  
706 my $cast = $hash->cast('regexp');
707  
708 # bless({ value => qr/(?^u:\{\})/ }, "Venus::Regexp")
709  
710 =back
711  
712 =over 4
713  
714 =item cast example 8
715  
716 package main;
717  
718 use Venus::Hash;
719  
720 my $hash = Venus::Hash->new;
721  
722 my $cast = $hash->cast('scalar');
723  
724 # bless({ value => \{} }, "Venus::Scalar")
725  
726 =back
727  
728 =over 4
729  
730 =item cast example 9
731  
732 package main;
733  
734 use Venus::Hash;
735  
736 my $hash = Venus::Hash->new;
737  
738 my $cast = $hash->cast('string');
739  
740 # bless({ value => "{}" }, "Venus::String")
741  
742 =back
743  
744 =over 4
745  
746 =item cast example 10
747  
748 package main;
749  
750 use Venus::Hash;
751  
752 my $hash = Venus::Hash->new;
753  
754 my $cast = $hash->cast('undef');
755  
756 # bless({ value => undef }, "Venus::Undef")
757  
758 =back
759  
760 =cut
761  
762 =head2 count
763  
764 count() (number)
765  
766 The count method returns the total number of keys defined.
767  
768 I<Since C<0.01>>
769  
770 =over 4
771  
772 =item count example 1
773  
774 # given: synopsis;
775  
776 my $count = $hash->count;
777  
778 # 4
779  
780 =back
781  
782 =cut
783  
784 =head2 default
785  
786 default() (hashref)
787  
788 The default method returns the default value, i.e. C<{}>.
789  
790 I<Since C<0.01>>
791  
792 =over 4
793  
794 =item default example 1
795  
796 # given: synopsis;
797  
798 my $default = $hash->default;
799  
800 # {}
801  
802 =back
803  
804 =cut
805  
806 =head2 delete
807  
808 delete(string $key) (any)
809  
810 The delete method returns the value matching the key specified in the argument
811 and returns the value.
812  
813 I<Since C<0.01>>
814  
815 =over 4
816  
817 =item delete example 1
818  
819 # given: synopsis;
820  
821 my $delete = $hash->delete(1);
822  
823 # 2
824  
825 =back
826  
827 =cut
828  
829 =head2 each
830  
831 each(coderef $code) (arrayref)
832  
833 The each method executes callback for each element in the hash passing the
834 routine the key and value at the current position in the loop. This method can
835 return a list of values in list-context.
836  
837 I<Since C<0.01>>
838  
839 =over 4
840  
841 =item each example 1
842  
843 # given: synopsis;
844  
845 my $each = $hash->each(sub {
846 [$_]
847 });
848  
849 # [[2], [4], [6], [8]]
850  
851 =back
852  
853 =over 4
854  
855 =item each example 2
856  
857 # given: synopsis;
858  
859 my $each = $hash->each(sub {
860 my ($key, $value) = @_;
861  
862 [$key, $value]
863 });
864  
865 # [[1, 2], [3, 4], [5, 6], [7, 8]]
866  
867 =back
868  
869 =cut
870  
871 =head2 empty
872  
873 empty() (hashref)
874  
875 The empty method drops all elements from the hash.
876  
877 I<Since C<0.01>>
878  
879 =over 4
880  
881 =item empty example 1
882  
883 # given: synopsis;
884  
885 my $empty = $hash->empty;
886  
887 # {}
888  
889 =back
890  
891 =cut
892  
893 =head2 eq
894  
895 eq(any $arg) (boolean)
896  
897 The eq method performs an I<"equals"> operation using the argument provided.
898  
899 I<Since C<0.08>>
900  
901 =over 4
902  
903 =item eq example 1
904  
905 package main;
906  
907 use Venus::Array;
908 use Venus::Hash;
909  
910 my $lvalue = Venus::Hash->new;
911 my $rvalue = Venus::Array->new;
912  
913 my $result = $lvalue->eq($rvalue);
914  
915 # 0
916  
917 =back
918  
919 =over 4
920  
921 =item eq example 2
922  
923 package main;
924  
925 use Venus::Code;
926 use Venus::Hash;
927  
928 my $lvalue = Venus::Hash->new;
929 my $rvalue = Venus::Code->new;
930  
931 my $result = $lvalue->eq($rvalue);
932  
933 # 0
934  
935 =back
936  
937 =over 4
938  
939 =item eq example 3
940  
941 package main;
942  
943 use Venus::Float;
944 use Venus::Hash;
945  
946 my $lvalue = Venus::Hash->new;
947 my $rvalue = Venus::Float->new;
948  
949 my $result = $lvalue->eq($rvalue);
950  
951 # 0
952  
953 =back
954  
955 =over 4
956  
957 =item eq example 4
958  
959 package main;
960  
961 use Venus::Hash;
962  
963 my $lvalue = Venus::Hash->new;
964 my $rvalue = Venus::Hash->new;
965  
966 my $result = $lvalue->eq($rvalue);
967  
968 # 1
969  
970 =back
971  
972 =over 4
973  
974 =item eq example 5
975  
976 package main;
977  
978 use Venus::Hash;
979 use Venus::Number;
980  
981 my $lvalue = Venus::Hash->new;
982 my $rvalue = Venus::Number->new;
983  
984 my $result = $lvalue->eq($rvalue);
985  
986 # 0
987  
988 =back
989  
990 =over 4
991  
992 =item eq example 6
993  
994 package main;
995  
996 use Venus::Hash;
997 use Venus::Regexp;
998  
999 my $lvalue = Venus::Hash->new;
1000 my $rvalue = Venus::Regexp->new;
1001  
1002 my $result = $lvalue->eq($rvalue);
1003  
1004 # 0
1005  
1006 =back
1007  
1008 =over 4
1009  
1010 =item eq example 7
1011  
1012 package main;
1013  
1014 use Venus::Hash;
1015 use Venus::Scalar;
1016  
1017 my $lvalue = Venus::Hash->new;
1018 my $rvalue = Venus::Scalar->new;
1019  
1020 my $result = $lvalue->eq($rvalue);
1021  
1022 # 0
1023  
1024 =back
1025  
1026 =over 4
1027  
1028 =item eq example 8
1029  
1030 package main;
1031  
1032 use Venus::Hash;
1033 use Venus::String;
1034  
1035 my $lvalue = Venus::Hash->new;
1036 my $rvalue = Venus::String->new;
1037  
1038 my $result = $lvalue->eq($rvalue);
1039  
1040 # 0
1041  
1042 =back
1043  
1044 =over 4
1045  
1046 =item eq example 9
1047  
1048 package main;
1049  
1050 use Venus::Hash;
1051 use Venus::Undef;
1052  
1053 my $lvalue = Venus::Hash->new;
1054 my $rvalue = Venus::Undef->new;
1055  
1056 my $result = $lvalue->eq($rvalue);
1057  
1058 # 0
1059  
1060 =back
1061  
1062 =cut
1063  
1064 =head2 exists
1065  
1066 exists(string $key) (boolean)
1067  
1068 The exists method returns true if the value matching the key specified in the
1069 argument exists, otherwise returns false.
1070  
1071 I<Since C<0.01>>
1072  
1073 =over 4
1074  
1075 =item exists example 1
1076  
1077 # given: synopsis;
1078  
1079 my $exists = $hash->exists(1);
1080  
1081 # 1
1082  
1083 =back
1084  
1085 =over 4
1086  
1087 =item exists example 2
1088  
1089 # given: synopsis;
1090  
1091 my $exists = $hash->exists(0);
1092  
1093 # 0
1094  
1095 =back
1096  
1097 =cut
1098  
1099 =head2 find
1100  
1101 find(string @data) (any)
1102  
1103 The find method traverses the data structure using the keys and indices
1104 provided, returning the value found or undef. In list-context, this method
1105 returns a tuple, i.e. the value found and boolean representing whether the
1106 match was successful.
1107  
1108 I<Since C<0.01>>
1109  
1110 =over 4
1111  
1112 =item find example 1
1113  
1114 package main;
1115  
1116 use Venus::Hash;
1117  
1118 my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']});
1119  
1120 my $find = $hash->find('foo', 'bar');
1121  
1122 # "baz"
1123  
1124 =back
1125  
1126 =over 4
1127  
1128 =item find example 2
1129  
1130 package main;
1131  
1132 use Venus::Hash;
1133  
1134 my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']});
1135  
1136 my $find = $hash->find('bar', 0);
1137  
1138 # "baz"
1139  
1140 =back
1141  
1142 =over 4
1143  
1144 =item find example 3
1145  
1146 package main;
1147  
1148 use Venus::Hash;
1149  
1150 my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']});
1151  
1152 my $find = $hash->find('bar');
1153  
1154 # ["baz"]
1155  
1156 =back
1157  
1158 =over 4
1159  
1160 =item find example 4
1161  
1162 package main;
1163  
1164 use Venus::Hash;
1165  
1166 my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']});
1167  
1168 my ($find, $exists) = $hash->find('baz');
1169  
1170 # (undef, 0)
1171  
1172 =back
1173  
1174 =cut
1175  
1176 =head2 ge
1177  
1178 ge(any $arg) (boolean)
1179  
1180 The ge method performs a I<"greater-than-or-equal-to"> operation using the
1181 argument provided.
1182  
1183 I<Since C<0.08>>
1184  
1185 =over 4
1186  
1187 =item ge example 1
1188  
1189 package main;
1190  
1191 use Venus::Array;
1192 use Venus::Hash;
1193  
1194 my $lvalue = Venus::Hash->new;
1195 my $rvalue = Venus::Array->new;
1196  
1197 my $result = $lvalue->ge($rvalue);
1198  
1199 # 0
1200  
1201 =back
1202  
1203 =over 4
1204  
1205 =item ge example 2
1206  
1207 package main;
1208  
1209 use Venus::Code;
1210 use Venus::Hash;
1211  
1212 my $lvalue = Venus::Hash->new;
1213 my $rvalue = Venus::Code->new;
1214  
1215 my $result = $lvalue->ge($rvalue);
1216  
1217 # 0
1218  
1219 =back
1220  
1221 =over 4
1222  
1223 =item ge example 3
1224  
1225 package main;
1226  
1227 use Venus::Float;
1228 use Venus::Hash;
1229  
1230 my $lvalue = Venus::Hash->new;
1231 my $rvalue = Venus::Float->new;
1232  
1233 my $result = $lvalue->ge($rvalue);
1234  
1235 # 1
1236  
1237 =back
1238  
1239 =over 4
1240  
1241 =item ge example 4
1242  
1243 package main;
1244  
1245 use Venus::Hash;
1246  
1247 my $lvalue = Venus::Hash->new;
1248 my $rvalue = Venus::Hash->new;
1249  
1250 my $result = $lvalue->ge($rvalue);
1251  
1252 # 1
1253  
1254 =back
1255  
1256 =over 4
1257  
1258 =item ge example 5
1259  
1260 package main;
1261  
1262 use Venus::Hash;
1263 use Venus::Number;
1264  
1265 my $lvalue = Venus::Hash->new;
1266 my $rvalue = Venus::Number->new;
1267  
1268 my $result = $lvalue->ge($rvalue);
1269  
1270 # 1
1271  
1272 =back
1273  
1274 =over 4
1275  
1276 =item ge example 6
1277  
1278 package main;
1279  
1280 use Venus::Hash;
1281 use Venus::Regexp;
1282  
1283 my $lvalue = Venus::Hash->new;
1284 my $rvalue = Venus::Regexp->new;
1285  
1286 my $result = $lvalue->ge($rvalue);
1287  
1288 # 0
1289  
1290 =back
1291  
1292 =over 4
1293  
1294 =item ge example 7
1295  
1296 package main;
1297  
1298 use Venus::Hash;
1299 use Venus::Scalar;
1300  
1301 my $lvalue = Venus::Hash->new;
1302 my $rvalue = Venus::Scalar->new;
1303  
1304 my $result = $lvalue->ge($rvalue);
1305  
1306 # 0
1307  
1308 =back
1309  
1310 =over 4
1311  
1312 =item ge example 8
1313  
1314 package main;
1315  
1316 use Venus::Hash;
1317 use Venus::String;
1318  
1319 my $lvalue = Venus::Hash->new;
1320 my $rvalue = Venus::String->new;
1321  
1322 my $result = $lvalue->ge($rvalue);
1323  
1324 # 1
1325  
1326 =back
1327  
1328 =over 4
1329  
1330 =item ge example 9
1331  
1332 package main;
1333  
1334 use Venus::Hash;
1335 use Venus::Undef;
1336  
1337 my $lvalue = Venus::Hash->new;
1338 my $rvalue = Venus::Undef->new;
1339  
1340 my $result = $lvalue->ge($rvalue);
1341  
1342 # 1
1343  
1344 =back
1345  
1346 =cut
1347  
1348 =head2 gele
1349  
1350 gele(any $arg1, any $arg2) (boolean)
1351  
1352 The gele method performs a I<"greater-than-or-equal-to"> operation on the 1st
1353 argument, and I<"lesser-than-or-equal-to"> operation on the 2nd argument.
1354  
1355 I<Since C<0.08>>
1356  
1357 =over 4
1358  
1359 =item gele example 1
1360  
1361 package main;
1362  
1363 use Venus::Array;
1364 use Venus::Hash;
1365  
1366 my $lvalue = Venus::Hash->new;
1367 my $rvalue = Venus::Array->new;
1368  
1369 my $result = $lvalue->gele($rvalue);
1370  
1371 # 0
1372  
1373 =back
1374  
1375 =over 4
1376  
1377 =item gele example 2
1378  
1379 package main;
1380  
1381 use Venus::Code;
1382 use Venus::Hash;
1383  
1384 my $lvalue = Venus::Hash->new;
1385 my $rvalue = Venus::Code->new;
1386  
1387 my $result = $lvalue->gele($rvalue);
1388  
1389 # 0
1390  
1391 =back
1392  
1393 =over 4
1394  
1395 =item gele example 3
1396  
1397 package main;
1398  
1399 use Venus::Float;
1400 use Venus::Hash;
1401  
1402 my $lvalue = Venus::Hash->new;
1403 my $rvalue = Venus::Float->new;
1404  
1405 my $result = $lvalue->gele($rvalue);
1406  
1407 # 0
1408  
1409 =back
1410  
1411 =over 4
1412  
1413 =item gele example 4
1414  
1415 package main;
1416  
1417 use Venus::Hash;
1418  
1419 my $lvalue = Venus::Hash->new;
1420 my $rvalue = Venus::Hash->new;
1421  
1422 my $result = $lvalue->gele($rvalue);
1423  
1424 # 0
1425  
1426 =back
1427  
1428 =over 4
1429  
1430 =item gele example 5
1431  
1432 package main;
1433  
1434 use Venus::Hash;
1435 use Venus::Number;
1436  
1437 my $lvalue = Venus::Hash->new;
1438 my $rvalue = Venus::Number->new;
1439  
1440 my $result = $lvalue->gele($rvalue);
1441  
1442 # 0
1443  
1444 =back
1445  
1446 =over 4
1447  
1448 =item gele example 6
1449  
1450 package main;
1451  
1452 use Venus::Hash;
1453 use Venus::Regexp;
1454  
1455 my $lvalue = Venus::Hash->new;
1456 my $rvalue = Venus::Regexp->new;
1457  
1458 my $result = $lvalue->gele($rvalue);
1459  
1460 # 0
1461  
1462 =back
1463  
1464 =over 4
1465  
1466 =item gele example 7
1467  
1468 package main;
1469  
1470 use Venus::Hash;
1471 use Venus::Scalar;
1472  
1473 my $lvalue = Venus::Hash->new;
1474 my $rvalue = Venus::Scalar->new;
1475  
1476 my $result = $lvalue->gele($rvalue);
1477  
1478 # 0
1479  
1480 =back
1481  
1482 =over 4
1483  
1484 =item gele example 8
1485  
1486 package main;
1487  
1488 use Venus::Hash;
1489 use Venus::String;
1490  
1491 my $lvalue = Venus::Hash->new;
1492 my $rvalue = Venus::String->new;
1493  
1494 my $result = $lvalue->gele($rvalue);
1495  
1496 # 0
1497  
1498 =back
1499  
1500 =over 4
1501  
1502 =item gele example 9
1503  
1504 package main;
1505  
1506 use Venus::Hash;
1507 use Venus::Undef;
1508  
1509 my $lvalue = Venus::Hash->new;
1510 my $rvalue = Venus::Undef->new;
1511  
1512 my $result = $lvalue->gele($rvalue);
1513  
1514 # 0
1515  
1516 =back
1517  
1518 =cut
1519  
1520 =head2 grep
1521  
1522 grep(coderef $code) (arrayref)
1523  
1524 The grep method executes callback for each key/value pair in the hash passing
1525 the routine the key and value at the current position in the loop and returning
1526 a new hash reference containing the elements for which the argument evaluated
1527 true. This method can return a list of values in list-context.
1528  
1529 I<Since C<0.01>>
1530  
1531 =over 4
1532  
1533 =item grep example 1
1534  
1535 # given: synopsis;
1536  
1537 my $grep = $hash->grep(sub {
1538 $_ >= 3
1539 });
1540  
1541 # [3..8]
1542  
1543 =back
1544  
1545 =over 4
1546  
1547 =item grep example 2
1548  
1549 # given: synopsis;
1550  
1551 my $grep = $hash->grep(sub {
1552 my ($key, $value) = @_;
1553  
1554 $value >= 3
1555 });
1556  
1557 # [3..8]
1558  
1559 =back
1560  
1561 =cut
1562  
1563 =head2 gt
1564  
1565 gt(any $arg) (boolean)
1566  
1567 The gt method performs a I<"greater-than"> operation using the argument provided.
1568  
1569 I<Since C<0.08>>
1570  
1571 =over 4
1572  
1573 =item gt example 1
1574  
1575 package main;
1576  
1577 use Venus::Array;
1578 use Venus::Hash;
1579  
1580 my $lvalue = Venus::Hash->new;
1581 my $rvalue = Venus::Array->new;
1582  
1583 my $result = $lvalue->gt($rvalue);
1584  
1585 # 0
1586  
1587 =back
1588  
1589 =over 4
1590  
1591 =item gt example 2
1592  
1593 package main;
1594  
1595 use Venus::Code;
1596 use Venus::Hash;
1597  
1598 my $lvalue = Venus::Hash->new;
1599 my $rvalue = Venus::Code->new;
1600  
1601 my $result = $lvalue->gt($rvalue);
1602  
1603 # 0
1604  
1605 =back
1606  
1607 =over 4
1608  
1609 =item gt example 3
1610  
1611 package main;
1612  
1613 use Venus::Float;
1614 use Venus::Hash;
1615  
1616 my $lvalue = Venus::Hash->new;
1617 my $rvalue = Venus::Float->new;
1618  
1619 my $result = $lvalue->gt($rvalue);
1620  
1621 # 1
1622  
1623 =back
1624  
1625 =over 4
1626  
1627 =item gt example 4
1628  
1629 package main;
1630  
1631 use Venus::Hash;
1632  
1633 my $lvalue = Venus::Hash->new;
1634 my $rvalue = Venus::Hash->new;
1635  
1636 my $result = $lvalue->gt($rvalue);
1637  
1638 # 0
1639  
1640 =back
1641  
1642 =over 4
1643  
1644 =item gt example 5
1645  
1646 package main;
1647  
1648 use Venus::Hash;
1649 use Venus::Number;
1650  
1651 my $lvalue = Venus::Hash->new;
1652 my $rvalue = Venus::Number->new;
1653  
1654 my $result = $lvalue->gt($rvalue);
1655  
1656 # 1
1657  
1658 =back
1659  
1660 =over 4
1661  
1662 =item gt example 6
1663  
1664 package main;
1665  
1666 use Venus::Hash;
1667 use Venus::Regexp;
1668  
1669 my $lvalue = Venus::Hash->new;
1670 my $rvalue = Venus::Regexp->new;
1671  
1672 my $result = $lvalue->gt($rvalue);
1673  
1674 # 0
1675  
1676 =back
1677  
1678 =over 4
1679  
1680 =item gt example 7
1681  
1682 package main;
1683  
1684 use Venus::Hash;
1685 use Venus::Scalar;
1686  
1687 my $lvalue = Venus::Hash->new;
1688 my $rvalue = Venus::Scalar->new;
1689  
1690 my $result = $lvalue->gt($rvalue);
1691  
1692 # 0
1693  
1694 =back
1695  
1696 =over 4
1697  
1698 =item gt example 8
1699  
1700 package main;
1701  
1702 use Venus::Hash;
1703 use Venus::String;
1704  
1705 my $lvalue = Venus::Hash->new;
1706 my $rvalue = Venus::String->new;
1707  
1708 my $result = $lvalue->gt($rvalue);
1709  
1710 # 1
1711  
1712 =back
1713  
1714 =over 4
1715  
1716 =item gt example 9
1717  
1718 package main;
1719  
1720 use Venus::Hash;
1721 use Venus::Undef;
1722  
1723 my $lvalue = Venus::Hash->new;
1724 my $rvalue = Venus::Undef->new;
1725  
1726 my $result = $lvalue->gt($rvalue);
1727  
1728 # 1
1729  
1730 =back
1731  
1732 =cut
1733  
1734 =head2 gtlt
1735  
1736 gtlt(any $arg1, any $arg2) (boolean)
1737  
1738 The gtlt method performs a I<"greater-than"> operation on the 1st argument, and
1739 I<"lesser-than"> operation on the 2nd argument.
1740  
1741 I<Since C<0.08>>
1742  
1743 =over 4
1744  
1745 =item gtlt example 1
1746  
1747 package main;
1748  
1749 use Venus::Array;
1750 use Venus::Hash;
1751  
1752 my $lvalue = Venus::Hash->new;
1753 my $rvalue = Venus::Array->new;
1754  
1755 my $result = $lvalue->gtlt($rvalue);
1756  
1757 # 0
1758  
1759 =back
1760  
1761 =over 4
1762  
1763 =item gtlt example 2
1764  
1765 package main;
1766  
1767 use Venus::Code;
1768 use Venus::Hash;
1769  
1770 my $lvalue = Venus::Hash->new;
1771 my $rvalue = Venus::Code->new;
1772  
1773 my $result = $lvalue->gtlt($rvalue);
1774  
1775 # 0
1776  
1777 =back
1778  
1779 =over 4
1780  
1781 =item gtlt example 3
1782  
1783 package main;
1784  
1785 use Venus::Float;
1786 use Venus::Hash;
1787  
1788 my $lvalue = Venus::Hash->new;
1789 my $rvalue = Venus::Float->new;
1790  
1791 my $result = $lvalue->gtlt($rvalue);
1792  
1793 # 0
1794  
1795 =back
1796  
1797 =over 4
1798  
1799 =item gtlt example 4
1800  
1801 package main;
1802  
1803 use Venus::Hash;
1804  
1805 my $lvalue = Venus::Hash->new;
1806 my $rvalue = Venus::Hash->new;
1807  
1808 my $result = $lvalue->gtlt($rvalue);
1809  
1810 # 0
1811  
1812 =back
1813  
1814 =over 4
1815  
1816 =item gtlt example 5
1817  
1818 package main;
1819  
1820 use Venus::Hash;
1821 use Venus::Number;
1822  
1823 my $lvalue = Venus::Hash->new;
1824 my $rvalue = Venus::Number->new;
1825  
1826 my $result = $lvalue->gtlt($rvalue);
1827  
1828 # 0
1829  
1830 =back
1831  
1832 =over 4
1833  
1834 =item gtlt example 6
1835  
1836 package main;
1837  
1838 use Venus::Hash;
1839 use Venus::Regexp;
1840  
1841 my $lvalue = Venus::Hash->new;
1842 my $rvalue = Venus::Regexp->new;
1843  
1844 my $result = $lvalue->gtlt($rvalue);
1845  
1846 # 0
1847  
1848 =back
1849  
1850 =over 4
1851  
1852 =item gtlt example 7
1853  
1854 package main;
1855  
1856 use Venus::Hash;
1857 use Venus::Scalar;
1858  
1859 my $lvalue = Venus::Hash->new;
1860 my $rvalue = Venus::Scalar->new;
1861  
1862 my $result = $lvalue->gtlt($rvalue);
1863  
1864 # 0
1865  
1866 =back
1867  
1868 =over 4
1869  
1870 =item gtlt example 8
1871  
1872 package main;
1873  
1874 use Venus::Hash;
1875 use Venus::String;
1876  
1877 my $lvalue = Venus::Hash->new;
1878 my $rvalue = Venus::String->new;
1879  
1880 my $result = $lvalue->gtlt($rvalue);
1881  
1882 # 0
1883  
1884 =back
1885  
1886 =over 4
1887  
1888 =item gtlt example 9
1889  
1890 package main;
1891  
1892 use Venus::Hash;
1893 use Venus::Undef;
1894  
1895 my $lvalue = Venus::Hash->new;
1896 my $rvalue = Venus::Undef->new;
1897  
1898 my $result = $lvalue->gtlt($rvalue);
1899  
1900 # 0
1901  
1902 =back
1903  
1904 =cut
1905  
1906 =head2 iterator
1907  
1908 iterator() (coderef)
1909  
1910 The iterator method returns a code reference which can be used to iterate over
1911 the hash. Each time the iterator is executed it will return the values of the
1912 next element in the hash until all elements have been seen, at which point the
1913 iterator will return an undefined value. This method can return a tuple with
1914 the key and value in list-context.
1915  
1916 I<Since C<0.01>>
1917  
1918 =over 4
1919  
1920 =item iterator example 1
1921  
1922 # given: synopsis;
1923  
1924 my $iterator = $hash->iterator;
1925  
1926 # sub { ... }
1927  
1928 # while (my $value = $iterator->()) {
1929 # say $value; # 1
1930 # }
1931  
1932 =back
1933  
1934 =over 4
1935  
1936 =item iterator example 2
1937  
1938 # given: synopsis;
1939  
1940 my $iterator = $hash->iterator;
1941  
1942 # sub { ... }
1943  
1944 # while (grep defined, my ($key, $value) = $iterator->()) {
1945 # say $value; # 1
1946 # }
1947  
1948 =back
1949  
1950 =cut
1951  
1952 =head2 keys
1953  
1954 keys() (arrayref)
1955  
1956 The keys method returns an array reference consisting of all the keys in the
1957 hash.
1958  
1959 I<Since C<0.01>>
1960  
1961 =over 4
1962  
1963 =item keys example 1
1964  
1965 # given: synopsis;
1966  
1967 my $keys = $hash->keys;
1968  
1969 # [1, 3, 5, 7]
1970  
1971 =back
1972  
1973 =cut
1974  
1975 =head2 le
1976  
1977 le(any $arg) (boolean)
1978  
1979 The le method performs a I<"lesser-than-or-equal-to"> operation using the
1980 argument provided.
1981  
1982 I<Since C<0.08>>
1983  
1984 =over 4
1985  
1986 =item le example 1
1987  
1988 package main;
1989  
1990 use Venus::Array;
1991 use Venus::Hash;
1992  
1993 my $lvalue = Venus::Hash->new;
1994 my $rvalue = Venus::Array->new;
1995  
1996 my $result = $lvalue->le($rvalue);
1997  
1998 # 0
1999  
2000 =back
2001  
2002 =over 4
2003  
2004 =item le example 2
2005  
2006 package main;
2007  
2008 use Venus::Code;
2009 use Venus::Hash;
2010  
2011 my $lvalue = Venus::Hash->new;
2012 my $rvalue = Venus::Code->new;
2013  
2014 my $result = $lvalue->le($rvalue);
2015  
2016 # 1
2017  
2018 =back
2019  
2020 =over 4
2021  
2022 =item le example 3
2023  
2024 package main;
2025  
2026 use Venus::Float;
2027 use Venus::Hash;
2028  
2029 my $lvalue = Venus::Hash->new;
2030 my $rvalue = Venus::Float->new;
2031  
2032 my $result = $lvalue->le($rvalue);
2033  
2034 # 0
2035  
2036 =back
2037  
2038 =over 4
2039  
2040 =item le example 4
2041  
2042 package main;
2043  
2044 use Venus::Hash;
2045  
2046 my $lvalue = Venus::Hash->new;
2047 my $rvalue = Venus::Hash->new;
2048  
2049 my $result = $lvalue->le($rvalue);
2050  
2051 # 1
2052  
2053 =back
2054  
2055 =over 4
2056  
2057 =item le example 5
2058  
2059 package main;
2060  
2061 use Venus::Hash;
2062 use Venus::Number;
2063  
2064 my $lvalue = Venus::Hash->new;
2065 my $rvalue = Venus::Number->new;
2066  
2067 my $result = $lvalue->le($rvalue);
2068  
2069 # 0
2070  
2071 =back
2072  
2073 =over 4
2074  
2075 =item le example 6
2076  
2077 package main;
2078  
2079 use Venus::Hash;
2080 use Venus::Regexp;
2081  
2082 my $lvalue = Venus::Hash->new;
2083 my $rvalue = Venus::Regexp->new;
2084  
2085 my $result = $lvalue->le($rvalue);
2086  
2087 # 1
2088  
2089 =back
2090  
2091 =over 4
2092  
2093 =item le example 7
2094  
2095 package main;
2096  
2097 use Venus::Hash;
2098 use Venus::Scalar;
2099  
2100 my $lvalue = Venus::Hash->new;
2101 my $rvalue = Venus::Scalar->new;
2102  
2103 my $result = $lvalue->le($rvalue);
2104  
2105 # 0
2106  
2107 =back
2108  
2109 =over 4
2110  
2111 =item le example 8
2112  
2113 package main;
2114  
2115 use Venus::Hash;
2116 use Venus::String;
2117  
2118 my $lvalue = Venus::Hash->new;
2119 my $rvalue = Venus::String->new;
2120  
2121 my $result = $lvalue->le($rvalue);
2122  
2123 # 0
2124  
2125 =back
2126  
2127 =over 4
2128  
2129 =item le example 9
2130  
2131 package main;
2132  
2133 use Venus::Hash;
2134 use Venus::Undef;
2135  
2136 my $lvalue = Venus::Hash->new;
2137 my $rvalue = Venus::Undef->new;
2138  
2139 my $result = $lvalue->le($rvalue);
2140  
2141 # 0
2142  
2143 =back
2144  
2145 =cut
2146  
2147 =head2 length
2148  
2149 length() (number)
2150  
2151 The length method returns the total number of keys defined, and is an alias for
2152 the L</count> method.
2153  
2154 I<Since C<0.08>>
2155  
2156 =over 4
2157  
2158 =item length example 1
2159  
2160 # given: synopsis;
2161  
2162 my $length = $hash->length;
2163  
2164 # 4
2165  
2166 =back
2167  
2168 =cut
2169  
2170 =head2 list
2171  
2172 list() (any)
2173  
2174 The list method returns a shallow copy of the underlying hash reference as an
2175 array reference.
2176  
2177 I<Since C<0.01>>
2178  
2179 =over 4
2180  
2181 =item list example 1
2182  
2183 # given: synopsis;
2184  
2185 my $list = $hash->list;
2186  
2187 # 4
2188  
2189 =back
2190  
2191 =over 4
2192  
2193 =item list example 2
2194  
2195 # given: synopsis;
2196  
2197 my @list = $hash->list;
2198  
2199 # (1..8)
2200  
2201 =back
2202  
2203 =cut
2204  
2205 =head2 lt
2206  
2207 lt(any $arg) (boolean)
2208  
2209 The lt method performs a I<"lesser-than"> operation using the argument provided.
2210  
2211 I<Since C<0.08>>
2212  
2213 =over 4
2214  
2215 =item lt example 1
2216  
2217 package main;
2218  
2219 use Venus::Array;
2220 use Venus::Hash;
2221  
2222 my $lvalue = Venus::Hash->new;
2223 my $rvalue = Venus::Array->new;
2224  
2225 my $result = $lvalue->lt($rvalue);
2226  
2227 # 0
2228  
2229 =back
2230  
2231 =over 4
2232  
2233 =item lt example 2
2234  
2235 package main;
2236  
2237 use Venus::Code;
2238 use Venus::Hash;
2239  
2240 my $lvalue = Venus::Hash->new;
2241 my $rvalue = Venus::Code->new;
2242  
2243 my $result = $lvalue->lt($rvalue);
2244  
2245 # 1
2246  
2247 =back
2248  
2249 =over 4
2250  
2251 =item lt example 3
2252  
2253 package main;
2254  
2255 use Venus::Float;
2256 use Venus::Hash;
2257  
2258 my $lvalue = Venus::Hash->new;
2259 my $rvalue = Venus::Float->new;
2260  
2261 my $result = $lvalue->lt($rvalue);
2262  
2263 # 0
2264  
2265 =back
2266  
2267 =over 4
2268  
2269 =item lt example 4
2270  
2271 package main;
2272  
2273 use Venus::Hash;
2274  
2275 my $lvalue = Venus::Hash->new;
2276 my $rvalue = Venus::Hash->new;
2277  
2278 my $result = $lvalue->lt($rvalue);
2279  
2280 # 0
2281  
2282 =back
2283  
2284 =over 4
2285  
2286 =item lt example 5
2287  
2288 package main;
2289  
2290 use Venus::Hash;
2291 use Venus::Number;
2292  
2293 my $lvalue = Venus::Hash->new;
2294 my $rvalue = Venus::Number->new;
2295  
2296 my $result = $lvalue->lt($rvalue);
2297  
2298 # 0
2299  
2300 =back
2301  
2302 =over 4
2303  
2304 =item lt example 6
2305  
2306 package main;
2307  
2308 use Venus::Hash;
2309 use Venus::Regexp;
2310  
2311 my $lvalue = Venus::Hash->new;
2312 my $rvalue = Venus::Regexp->new;
2313  
2314 my $result = $lvalue->lt($rvalue);
2315  
2316 # 1
2317  
2318 =back
2319  
2320 =over 4
2321  
2322 =item lt example 7
2323  
2324 package main;
2325  
2326 use Venus::Hash;
2327 use Venus::Scalar;
2328  
2329 my $lvalue = Venus::Hash->new;
2330 my $rvalue = Venus::Scalar->new;
2331  
2332 my $result = $lvalue->lt($rvalue);
2333  
2334 # 0
2335  
2336 =back
2337  
2338 =over 4
2339  
2340 =item lt example 8
2341  
2342 package main;
2343  
2344 use Venus::Hash;
2345 use Venus::String;
2346  
2347 my $lvalue = Venus::Hash->new;
2348 my $rvalue = Venus::String->new;
2349  
2350 my $result = $lvalue->lt($rvalue);
2351  
2352 # 0
2353  
2354 =back
2355  
2356 =over 4
2357  
2358 =item lt example 9
2359  
2360 package main;
2361  
2362 use Venus::Hash;
2363 use Venus::Undef;
2364  
2365 my $lvalue = Venus::Hash->new;
2366 my $rvalue = Venus::Undef->new;
2367  
2368 my $result = $lvalue->lt($rvalue);
2369  
2370 # 0
2371  
2372 =back
2373  
2374 =cut
2375  
2376 =head2 map
2377  
2378 map(coderef $code) (arrayref)
2379  
2380 The map method executes callback for each key/value in the hash passing the
2381 routine the value at the current position in the loop and returning a new hash
2382 reference containing the elements for which the argument returns a value or
2383 non-empty list. This method can return a list of values in list-context.
2384  
2385 I<Since C<0.01>>
2386  
2387 =over 4
2388  
2389 =item map example 1
2390  
2391 # given: synopsis;
2392  
2393 my $map = $hash->map(sub {
2394 $_ * 2
2395 });
2396  
2397 # [4, 8, 12, 16]
2398  
2399 =back
2400  
2401 =over 4
2402  
2403 =item map example 2
2404  
2405 # given: synopsis;
2406  
2407 my $map = $hash->map(sub {
2408 my ($key, $value) = @_;
2409  
2410 [$key, ($value * 2)]
2411 });
2412  
2413 # [[1, 4], [3, 8], [5, 12], [7, 16]]
2414  
2415 =back
2416  
2417 =cut
2418  
2419 =head2 merge
2420  
2421 merge(hashref @data) (hashref)
2422  
2423 The merge method returns a hash reference where the elements in the hash and
2424 the elements in the argument(s) are merged. This operation performs a deep
2425 merge and clones the datasets to ensure no side-effects.
2426  
2427 I<Since C<0.01>>
2428  
2429 =over 4
2430  
2431 =item merge example 1
2432  
2433 # given: synopsis;
2434  
2435 my $merge = $hash->merge({1 => 'a'});
2436  
2437 # { 1 => "a", 3 => 4, 5 => 6, 7 => 8 }
2438  
2439 =back
2440  
2441 =over 4
2442  
2443 =item merge example 2
2444  
2445 # given: synopsis;
2446  
2447 my $merge = $hash->merge({1 => 'a'}, {5 => 'b'});
2448  
2449 # { 1 => "a", 3 => 4, 5 => "b", 7 => 8 }
2450  
2451 =back
2452  
2453 =cut
2454  
2455 =head2 ne
2456  
2457 ne(any $arg) (boolean)
2458  
2459 The ne method performs a I<"not-equal-to"> operation using the argument provided.
2460  
2461 I<Since C<0.08>>
2462  
2463 =over 4
2464  
2465 =item ne example 1
2466  
2467 package main;
2468  
2469 use Venus::Array;
2470 use Venus::Hash;
2471  
2472 my $lvalue = Venus::Hash->new;
2473 my $rvalue = Venus::Array->new;
2474  
2475 my $result = $lvalue->ne($rvalue);
2476  
2477 # 1
2478  
2479 =back
2480  
2481 =over 4
2482  
2483 =item ne example 2
2484  
2485 package main;
2486  
2487 use Venus::Code;
2488 use Venus::Hash;
2489  
2490 my $lvalue = Venus::Hash->new;
2491 my $rvalue = Venus::Code->new;
2492  
2493 my $result = $lvalue->ne($rvalue);
2494  
2495 # 1
2496  
2497 =back
2498  
2499 =over 4
2500  
2501 =item ne example 3
2502  
2503 package main;
2504  
2505 use Venus::Float;
2506 use Venus::Hash;
2507  
2508 my $lvalue = Venus::Hash->new;
2509 my $rvalue = Venus::Float->new;
2510  
2511 my $result = $lvalue->ne($rvalue);
2512  
2513 # 1
2514  
2515 =back
2516  
2517 =over 4
2518  
2519 =item ne example 4
2520  
2521 package main;
2522  
2523 use Venus::Hash;
2524  
2525 my $lvalue = Venus::Hash->new;
2526 my $rvalue = Venus::Hash->new;
2527  
2528 my $result = $lvalue->ne($rvalue);
2529  
2530 # 0
2531  
2532 =back
2533  
2534 =over 4
2535  
2536 =item ne example 5
2537  
2538 package main;
2539  
2540 use Venus::Hash;
2541 use Venus::Number;
2542  
2543 my $lvalue = Venus::Hash->new;
2544 my $rvalue = Venus::Number->new;
2545  
2546 my $result = $lvalue->ne($rvalue);
2547  
2548 # 1
2549  
2550 =back
2551  
2552 =over 4
2553  
2554 =item ne example 6
2555  
2556 package main;
2557  
2558 use Venus::Hash;
2559 use Venus::Regexp;
2560  
2561 my $lvalue = Venus::Hash->new;
2562 my $rvalue = Venus::Regexp->new;
2563  
2564 my $result = $lvalue->ne($rvalue);
2565  
2566 # 1
2567  
2568 =back
2569  
2570 =over 4
2571  
2572 =item ne example 7
2573  
2574 package main;
2575  
2576 use Venus::Hash;
2577 use Venus::Scalar;
2578  
2579 my $lvalue = Venus::Hash->new;
2580 my $rvalue = Venus::Scalar->new;
2581  
2582 my $result = $lvalue->ne($rvalue);
2583  
2584 # 1
2585  
2586 =back
2587  
2588 =over 4
2589  
2590 =item ne example 8
2591  
2592 package main;
2593  
2594 use Venus::Hash;
2595 use Venus::String;
2596  
2597 my $lvalue = Venus::Hash->new;
2598 my $rvalue = Venus::String->new;
2599  
2600 my $result = $lvalue->ne($rvalue);
2601  
2602 # 1
2603  
2604 =back
2605  
2606 =over 4
2607  
2608 =item ne example 9
2609  
2610 package main;
2611  
2612 use Venus::Hash;
2613 use Venus::Undef;
2614  
2615 my $lvalue = Venus::Hash->new;
2616 my $rvalue = Venus::Undef->new;
2617  
2618 my $result = $lvalue->ne($rvalue);
2619  
2620 # 1
2621  
2622 =back
2623  
2624 =cut
2625  
2626 =head2 none
2627  
2628 none(coderef $code) (boolean)
2629  
2630 The none method returns true if none of the elements in the array meet the
2631 criteria set by the operand and rvalue.
2632  
2633 I<Since C<0.01>>
2634  
2635 =over 4
2636  
2637 =item none example 1
2638  
2639 # given: synopsis;
2640  
2641 my $none = $hash->none(sub {
2642 $_ < 1
2643 });
2644  
2645 # 1
2646  
2647 =back
2648  
2649 =over 4
2650  
2651 =item none example 2
2652  
2653 # given: synopsis;
2654  
2655 my $none = $hash->none(sub {
2656 my ($key, $value) = @_;
2657  
2658 $value < 1
2659 });
2660  
2661 # 1
2662  
2663 =back
2664  
2665 =cut
2666  
2667 =head2 one
2668  
2669 one(coderef $code) (boolean)
2670  
2671 The one method returns true if only one of the elements in the array meet the
2672 criteria set by the operand and rvalue.
2673  
2674 I<Since C<0.01>>
2675  
2676 =over 4
2677  
2678 =item one example 1
2679  
2680 # given: synopsis;
2681  
2682 my $one = $hash->one(sub {
2683 $_ == 2
2684 });
2685  
2686 # 1
2687  
2688 =back
2689  
2690 =over 4
2691  
2692 =item one example 2
2693  
2694 # given: synopsis;
2695  
2696 my $one = $hash->one(sub {
2697 my ($key, $value) = @_;
2698  
2699 $value == 2
2700 });
2701  
2702 # 1
2703  
2704 =back
2705  
2706 =cut
2707  
2708 =head2 pairs
2709  
2710 pairs() (arrayref)
2711  
2712 The pairs method is an alias to the pairs_array method. This method can return
2713 a list of values in list-context.
2714  
2715 I<Since C<0.01>>
2716  
2717 =over 4
2718  
2719 =item pairs example 1
2720  
2721 # given: synopsis;
2722  
2723 my $pairs = $hash->pairs;
2724  
2725 # [[1, 2], [3, 4], [5, 6], [7, 8]]
2726  
2727 =back
2728  
2729 =cut
2730  
2731 =head2 path
2732  
2733 path(string $expr) (any)
2734  
2735 The path method traverses the data structure using the path expr provided,
2736 returning the value found or undef. In list-context, this method returns a
2737 tuple, i.e. the value found and boolean representing whether the match was
2738 successful.
2739  
2740 I<Since C<0.01>>
2741  
2742 =over 4
2743  
2744 =item path example 1
2745  
2746 package main;
2747  
2748 use Venus::Hash;
2749  
2750 my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']});
2751  
2752 my $path = $hash->path('/foo/bar');
2753  
2754 # "baz"
2755  
2756 =back
2757  
2758 =over 4
2759  
2760 =item path example 2
2761  
2762 package main;
2763  
2764 use Venus::Hash;
2765  
2766 my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']});
2767  
2768 my $path = $hash->path('/bar/0');
2769  
2770 # "baz"
2771  
2772 =back
2773  
2774 =over 4
2775  
2776 =item path example 3
2777  
2778 package main;
2779  
2780 use Venus::Hash;
2781  
2782 my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']});
2783  
2784 my $path = $hash->path('/bar');
2785  
2786 # ["baz"]
2787  
2788 =back
2789  
2790 =over 4
2791  
2792 =item path example 4
2793  
2794 package main;
2795  
2796 use Venus::Hash;
2797  
2798 my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']});
2799  
2800 my ($path, $exists) = $hash->path('/baz');
2801  
2802 # (undef, 0)
2803  
2804 =back
2805  
2806 =cut
2807  
2808 =head2 puts
2809  
2810 puts(any @args) (arrayref)
2811  
2812 The puts method select values from within the underlying data structure using
2813 L<Venus::Hash/path>, optionally assigning the value to the preceeding scalar
2814 reference and returns all the values selected.
2815  
2816 I<Since C<3.20>>
2817  
2818 =over 4
2819  
2820 =item puts example 1
2821  
2822 package main;
2823  
2824 use Venus::Hash;
2825  
2826 my $hash = Venus::Hash->new({
2827 size => "small",
2828 fruit => "apple",
2829 meta => {
2830 expiry => '5d',
2831 },
2832 color => "red",
2833 });
2834  
2835 my $puts = $hash->puts(undef, 'fruit', undef, 'color');
2836  
2837 # ["apple", "red"]
2838  
2839 =back
2840  
2841 =over 4
2842  
2843 =item puts example 2
2844  
2845 package main;
2846  
2847 use Venus::Hash;
2848  
2849 my $hash = Venus::Hash->new({
2850 size => "small",
2851 fruit => "apple",
2852 meta => {
2853 expiry => '5d',
2854 },
2855 color => "red",
2856 });
2857  
2858 $hash->puts(\my $fruit, 'fruit', \my $expiry, 'meta.expiry');
2859  
2860 my $puts = [$fruit, $expiry];
2861  
2862 # ["apple", "5d"]
2863  
2864 =back
2865  
2866 =over 4
2867  
2868 =item puts example 3
2869  
2870 package main;
2871  
2872 use Venus::Hash;
2873  
2874 my $hash = Venus::Hash->new({
2875 size => "small",
2876 fruit => "apple",
2877 meta => {
2878 expiry => '5d',
2879 },
2880 color => "red",
2881 });
2882  
2883 $hash->puts(
2884 \my $fruit, 'fruit',
2885 \my $color, 'color',
2886 \my $expiry, 'meta.expiry',
2887 \my $ripe, 'meta.ripe',
2888 );
2889  
2890 my $puts = [$fruit, $color, $expiry, $ripe];
2891  
2892 # ["apple", "red", "5d", undef]
2893  
2894 =back
2895  
2896 =over 4
2897  
2898 =item puts example 4
2899  
2900 package main;
2901  
2902 use Venus::Hash;
2903  
2904 my $hash = Venus::Hash->new({set => [1..20]});
2905  
2906 $hash->puts(
2907 \my $a, 'set.0',
2908 \my $b, 'set.1',
2909 \my $m, ['set', '2:-2'],
2910 \my $x, 'set.18',
2911 \my $y, 'set.19',
2912 );
2913  
2914 my $puts = [$a, $b, $m, $x, $y];
2915  
2916 # [1, 2, [3..18], 19, 20]
2917  
2918 =back
2919  
2920 =cut
2921  
2922 =head2 random
2923  
2924 random() (any)
2925  
2926 The random method returns a random element from the array.
2927  
2928 I<Since C<0.01>>
2929  
2930 =over 4
2931  
2932 =item random example 1
2933  
2934 # given: synopsis;
2935  
2936 my $random = $hash->random;
2937  
2938 # 6
2939  
2940 # my $random = $hash->random;
2941  
2942 # 4
2943  
2944 =back
2945  
2946 =cut
2947  
2948 =head2 reset
2949  
2950 reset() (arrayref)
2951  
2952 The reset method returns nullifies the value of each element in the hash.
2953  
2954 I<Since C<0.01>>
2955  
2956 =over 4
2957  
2958 =item reset example 1
2959  
2960 # given: synopsis;
2961  
2962 my $reset = $hash->reset;
2963  
2964 # { 1 => undef, 3 => undef, 5 => undef, 7 => undef }
2965  
2966 =back
2967  
2968 =cut
2969  
2970 =head2 reverse
2971  
2972 reverse() (hashref)
2973  
2974 The reverse method returns a hash reference consisting of the hash's keys and
2975 values inverted. Note, keys with undefined values will be dropped.
2976  
2977 I<Since C<0.01>>
2978  
2979 =over 4
2980  
2981 =item reverse example 1
2982  
2983 # given: synopsis;
2984  
2985 my $reverse = $hash->reverse;
2986  
2987 # { 2 => 1, 4 => 3, 6 => 5, 8 => 7 }
2988  
2989 =back
2990  
2991 =cut
2992  
2993 =head2 slice
2994  
2995 slice(string @keys) (arrayref)
2996  
2997 The slice method returns an array reference of the values that correspond to
2998 the key(s) specified in the arguments.
2999  
3000 I<Since C<0.01>>
3001  
3002 =over 4
3003  
3004 =item slice example 1
3005  
3006 # given: synopsis;
3007  
3008 my $slice = $hash->slice(1, 3);
3009  
3010 # [2, 4]
3011  
3012 =back
3013  
3014 =cut
3015  
3016 =head2 tv
3017  
3018 tv(any $arg) (boolean)
3019  
3020 The tv method performs a I<"type-and-value-equal-to"> operation using argument
3021 provided.
3022  
3023 I<Since C<0.08>>
3024  
3025 =over 4
3026  
3027 =item tv example 1
3028  
3029 package main;
3030  
3031 use Venus::Array;
3032 use Venus::Hash;
3033  
3034 my $lvalue = Venus::Hash->new;
3035 my $rvalue = Venus::Array->new;
3036  
3037 my $result = $lvalue->tv($rvalue);
3038  
3039 # 0
3040  
3041 =back
3042  
3043 =over 4
3044  
3045 =item tv example 2
3046  
3047 package main;
3048  
3049 use Venus::Code;
3050 use Venus::Hash;
3051  
3052 my $lvalue = Venus::Hash->new;
3053 my $rvalue = Venus::Code->new;
3054  
3055 my $result = $lvalue->tv($rvalue);
3056  
3057 # 0
3058  
3059 =back
3060  
3061 =over 4
3062  
3063 =item tv example 3
3064  
3065 package main;
3066  
3067 use Venus::Float;
3068 use Venus::Hash;
3069  
3070 my $lvalue = Venus::Hash->new;
3071 my $rvalue = Venus::Float->new;
3072  
3073 my $result = $lvalue->tv($rvalue);
3074  
3075 # 0
3076  
3077 =back
3078  
3079 =over 4
3080  
3081 =item tv example 4
3082  
3083 package main;
3084  
3085 use Venus::Hash;
3086  
3087 my $lvalue = Venus::Hash->new;
3088 my $rvalue = Venus::Hash->new;
3089  
3090 my $result = $lvalue->tv($rvalue);
3091  
3092 # 1
3093  
3094 =back
3095  
3096 =over 4
3097  
3098 =item tv example 5
3099  
3100 package main;
3101  
3102 use Venus::Hash;
3103 use Venus::Number;
3104  
3105 my $lvalue = Venus::Hash->new;
3106 my $rvalue = Venus::Number->new;
3107  
3108 my $result = $lvalue->tv($rvalue);
3109  
3110 # 0
3111  
3112 =back
3113  
3114 =over 4
3115  
3116 =item tv example 6
3117  
3118 package main;
3119  
3120 use Venus::Hash;
3121 use Venus::Regexp;
3122  
3123 my $lvalue = Venus::Hash->new;
3124 my $rvalue = Venus::Regexp->new;
3125  
3126 my $result = $lvalue->tv($rvalue);
3127  
3128 # 0
3129  
3130 =back
3131  
3132 =over 4
3133  
3134 =item tv example 7
3135  
3136 package main;
3137  
3138 use Venus::Hash;
3139 use Venus::Scalar;
3140  
3141 my $lvalue = Venus::Hash->new;
3142 my $rvalue = Venus::Scalar->new;
3143  
3144 my $result = $lvalue->tv($rvalue);
3145  
3146 # 0
3147  
3148 =back
3149  
3150 =over 4
3151  
3152 =item tv example 8
3153  
3154 package main;
3155  
3156 use Venus::Hash;
3157 use Venus::String;
3158  
3159 my $lvalue = Venus::Hash->new;
3160 my $rvalue = Venus::String->new;
3161  
3162 my $result = $lvalue->tv($rvalue);
3163  
3164 # 0
3165  
3166 =back
3167  
3168 =over 4
3169  
3170 =item tv example 9
3171  
3172 package main;
3173  
3174 use Venus::Hash;
3175 use Venus::Undef;
3176  
3177 my $lvalue = Venus::Hash->new;
3178 my $rvalue = Venus::Undef->new;
3179  
3180 my $result = $lvalue->tv($rvalue);
3181  
3182 # 0
3183  
3184 =back
3185  
3186 =cut
3187  
3188 =head1 AUTHORS
3189  
3190 Awncorp, C<awncorp@cpan.org>
3191  
3192 =cut
3193  
3194 =head1 LICENSE
3195  
3196 Copyright (C) 2000, Awncorp, C<awncorp@cpan.org>.
3197  
3198 This program is free software, you can redistribute it and/or modify it under
3199 the terms of the Apache license version 2.0.
3200  
3201 =cut
« blib/lib/Venus/Meta.pm ↑ Summary blib/lib/Venus/Space.pm »