- Timestamp:
- 02/25/08 11:36:20 (5 years ago)
- Location:
- lang/perl/Data-Cloud/trunk
- Files:
-
- 1 added
- 1 modified
-
lib/Data/Cloud.pm (modified) (4 diffs)
-
t/03_filter.t (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Data-Cloud/trunk/lib/Data/Cloud.pm
r4060 r7116 9 9 10 10 sub new { 11 my ( $class, @args ) = @_; 11 my ( $class, %args ) = @_; 12 13 my $cs = delete $args{'case_sensitive'} || 0; 14 my $nn = delete $args{'allow_negative_number'} || 0; 12 15 13 16 my $self = bless { 14 data => {}, 17 data => {}, 18 cs => $cs, 19 nn => $nn, 15 20 }, $class; 16 21 … … 19 24 20 25 sub data { shift->{'data'} } 26 27 sub filter { 28 my ( $self, $word, $number ) = @_; 29 30 if ( ! $self->{'cs'} ) { 31 $word = lc $word; 32 } 33 34 if ( ! $self->{'nn'} ) { 35 $number = ( $number < 0 ) 36 ? 0 37 : $number 38 ; 39 } 40 41 return ( $word, $number ); 42 } 21 43 22 44 1; … … 47 69 =head2 new 48 70 49 my $cloud = Data::Cloud->new; 71 my $cloud = Data::Cloud->new( %options ); 72 73 This method is constructor of Data::Cloud. 74 75 The following option can be specified as arguments. 76 77 =over 78 79 =item C<'case_sensitive'> 80 81 If this option is true, Data::Cloud distinguishes between uppercase and lowercase letters. 82 And if this option is false, Data::Cloud does not distinguish between uppercase and lowercase letters. 83 84 This option is false by default. 85 86 =item C<'allow_negative_number'> 87 88 If this option is true, Data::Cloud permits the negative number. 89 And if this option is fase, Data::Cloud does not permits the negative number. 90 91 This option is false by default. 92 93 =back 50 94 51 95 =head2 set … … 81 125 my $count = $cloud->count($word); 82 126 127 =head2 filter 128 129 my ( $word, $number ) = $cloud->filter( $word => $number ); 130 131 This method processes a word and its number with constructor's options. 132 133 When Data::Cloud operates a word and the number, this method is called certainly. 134 83 135 =head2 data 84 136
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)