Add sprintf to String
[gitmo/Moose-Autobox.git] / lib / Moose / Autobox / String.pm
CommitLineData
6cf5bcf2 1package Moose::Autobox::String;
2use Moose::Role;
3
30e523b8 4our $VERSION = '0.11';
6cf5bcf2 5
31d40d73 6with 'Moose::Autobox::Value';
7
6cf5bcf2 8# perl built-ins
9
10sub lc { CORE::lc $_[0] }
11sub lcfirst { CORE::lcfirst $_[0] }
12sub uc { CORE::uc $_[0] }
13sub ucfirst { CORE::ucfirst $_[0] }
14sub chomp { CORE::chomp $_[0] }
15sub chop { CORE::chop $_[0] }
16sub reverse { CORE::reverse $_[0] }
17sub length { CORE::length $_[0] }
cfb0b828 18sub sprintf { CORE::sprintf $_[0], @_[1..$#_] }
bf868259 19sub lines { [ CORE::split '\n', $_[0] ] }
20sub words { [ CORE::split ' ', $_[0] ] }
680d0745 21sub index {
22 return CORE::index($_[0], $_[1]) if scalar @_ == 2;
23 return CORE::index($_[0], $_[1], $_[2]);
24}
dae37220 25sub rindex {
26 return CORE::rindex($_[0], $_[1]) if scalar @_ == 2;
27 return CORE::rindex($_[0], $_[1], $_[2]);
28}
2e99cc07 29sub split {
bf868259 30 return [ CORE::split($_[1], $_[0]) ] if scalar @_ == 2;
31 return [ CORE::split($_[1], $_[0], $_[2]) ];
2e99cc07 32}
6cf5bcf2 33
31d40d73 341;
35
36__END__
37
38=pod
39
40=head1 NAME
41
42Moose::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 52This 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
84This is equivalent to splitting on space.
85
86=item B<lines>
87
88This 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
100All complex software has bugs lurking in it, and this module is no
101exception. If you find a bug please either email me, or add the bug
102to cpan-RT.
103
104=head1 AUTHOR
105
106Stevan Little E<lt>stevan@iinteractive.comE<gt>
107
108=head1 COPYRIGHT AND LICENSE
109
ea4e64bf 110Copyright 2006-2008 by Infinity Interactive, Inc.
31d40d73 111
112L<http://www.iinteractive.com>
113
114This library is free software; you can redistribute it and/or modify
115it under the same terms as Perl itself.
116
dae37220 117=cut
118