Commit | Line | Data |
6cf5bcf2 |
1 | package Moose::Autobox::String; |
2 | use Moose::Role; |
3 | |
30e523b8 |
4 | our $VERSION = '0.11'; |
6cf5bcf2 |
5 | |
31d40d73 |
6 | with 'Moose::Autobox::Value'; |
7 | |
6cf5bcf2 |
8 | # perl built-ins |
9 | |
10 | sub lc { CORE::lc $_[0] } |
11 | sub lcfirst { CORE::lcfirst $_[0] } |
12 | sub uc { CORE::uc $_[0] } |
13 | sub ucfirst { CORE::ucfirst $_[0] } |
14 | sub chomp { CORE::chomp $_[0] } |
15 | sub chop { CORE::chop $_[0] } |
16 | sub reverse { CORE::reverse $_[0] } |
17 | sub length { CORE::length $_[0] } |
cfb0b828 |
18 | sub sprintf { CORE::sprintf $_[0], @_[1..$#_] } |
bf868259 |
19 | sub lines { [ CORE::split '\n', $_[0] ] } |
20 | sub words { [ CORE::split ' ', $_[0] ] } |
680d0745 |
21 | sub index { |
22 | return CORE::index($_[0], $_[1]) if scalar @_ == 2; |
23 | return CORE::index($_[0], $_[1], $_[2]); |
24 | } |
dae37220 |
25 | sub rindex { |
26 | return CORE::rindex($_[0], $_[1]) if scalar @_ == 2; |
27 | return CORE::rindex($_[0], $_[1], $_[2]); |
28 | } |
2e99cc07 |
29 | sub split { |
bf868259 |
30 | return [ CORE::split($_[1], $_[0]) ] if scalar @_ == 2; |
31 | return [ CORE::split($_[1], $_[0], $_[2]) ]; |
2e99cc07 |
32 | } |
6cf5bcf2 |
33 | |
31d40d73 |
34 | 1; |
35 | |
36 | __END__ |
37 | |
38 | =pod |
39 | |
40 | =head1 NAME |
41 | |
42 | Moose::Autobox::String - the String role |
43 | |
44 | =head1 SYNOPOSIS |
45 | |
46 | use Moose::Autobox; |
31d40d73 |
47 | |
48 | "Hello World"->uc; # HELLO WORLD |
49 | |
50 | =head1 DESCRIPTION |
51 | |
8937074a |
52 | This is a role to describes a String value. |
53 | |
260cc81f |
54 | =head1 METHODS |
55 | |
56 | =over 4 |
57 | |
260cc81f |
58 | =item B<chomp> |
59 | |
60 | =item B<chop> |
61 | |
62 | =item B<index> |
63 | |
64 | =item B<lc> |
65 | |
66 | =item B<lcfirst> |
67 | |
68 | =item B<length> |
69 | |
70 | =item B<reverse> |
71 | |
dae37220 |
72 | =item B<rindex> |
73 | |
260cc81f |
74 | =item B<uc> |
75 | |
76 | =item B<ucfirst> |
77 | |
c0ab09e3 |
78 | =item B<split> |
79 | |
80 | $string->split($pattern); |
81 | |
82 | =item B<words> |
83 | |
84 | This is equivalent to splitting on space. |
85 | |
86 | =item B<lines> |
87 | |
88 | This is equivalent to splitting on linelines. |
89 | |
260cc81f |
90 | =back |
91 | |
5272f13f |
92 | =over 4 |
93 | |
94 | =item B<meta> |
95 | |
96 | =back |
97 | |
31d40d73 |
98 | =head1 BUGS |
99 | |
100 | All complex software has bugs lurking in it, and this module is no |
101 | exception. If you find a bug please either email me, or add the bug |
102 | to cpan-RT. |
103 | |
104 | =head1 AUTHOR |
105 | |
106 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
107 | |
108 | =head1 COPYRIGHT AND LICENSE |
109 | |
ea4e64bf |
110 | Copyright 2006-2008 by Infinity Interactive, Inc. |
31d40d73 |
111 | |
112 | L<http://www.iinteractive.com> |
113 | |
114 | This library is free software; you can redistribute it and/or modify |
115 | it under the same terms as Perl itself. |
116 | |
dae37220 |
117 | =cut |
118 | |