| 1 | package Search::Tools::RegEx; | ||
| 2 | 26 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 26 | extends 'Search::Tools::Object'; | |
| 4 | 26 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | use overload | ||
| 6 | 0 | ▶ | '""' => sub { $_[0]->term; }, |
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 7 | 2 | ▶ | 'bool' => sub {1}, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 8 | 26 | fallback => 1; | |
| 9 | |||
| 10 | #use Data::Dump qw( dump ); | ||
| 11 | |||
| 12 | 26 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 26 | our $VERSION = '1.007'; | |
| 15 | |||
| 16 | 26 | my @ro_attrs = qw( | |
| 17 | plain | ||
| 18 | html | ||
| 19 | term | ||
| 20 | term_re | ||
| 21 | is_phrase | ||
| 22 | phrase_terms | ||
| 23 | ); | ||
| 24 | |||
| 25 | 26 | for my $attr (@ro_attrs) { | |
| 26 | 156 | has $attr => ( is => 'ro' ); | |
| 27 | } | ||
| 28 | |||
| 29 | =head1 NAME | ||
| 30 | |||
| 31 | Search::Tools::RegEx - regular expressions for terms | ||
| 32 | |||
| 33 | =head1 SYNOPSIS | ||
| 34 | |||
| 35 | my $regex = $query->regex_for('foo'); | ||
| 36 | like( 'foo', $regex->plain, "matches plain (no markup)"); | ||
| 37 | like( 'foo', $regex->html, "matches html (with markup)"); | ||
| 38 | ok( ! $regex->is_phrase, "foo is not a phrase"); | ||
| 39 | is( 'foo', $regex->term, "foo is the term"); | ||
| 40 | |||
| 41 | =head1 DESCRIPTION | ||
| 42 | |||
| 43 | |||
| 44 | =head1 METHODS | ||
| 45 | |||
| 46 | =head2 plain | ||
| 47 | |||
| 48 | =head2 html | ||
| 49 | |||
| 50 | =head2 term | ||
| 51 | |||
| 52 | =head2 term_re | ||
| 53 | |||
| 54 | =head2 is_phrase | ||
| 55 | |||
| 56 | =head2 phrase_terms | ||
| 57 | |||
| 58 | If B<is_phrase> is true, B<phrase_terms> will contain an ARRAY ref | ||
| 59 | of Search::Tools::RegEx objects, each one representing a term | ||
| 60 | in the phrase. | ||
| 61 | |||
| 62 | =cut | ||
| 63 | |||
| 64 | 26 | 1; | |
| 65 | |||
| 66 | __END__ | ||