Add sprintf to String
[gitmo/Moose-Autobox.git] / lib / Moose / Autobox / String.pm
1 package Moose::Autobox::String;
2 use Moose::Role;
3
4 our $VERSION = '0.11';
5
6 with 'Moose::Autobox::Value';
7
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] }
18 sub sprintf { CORE::sprintf $_[0], @_[1..$#_] }
19 sub lines   { [ CORE::split '\n', $_[0] ] }
20 sub words   { [ CORE::split ' ',  $_[0] ] }
21 sub index   { 
22     return CORE::index($_[0], $_[1]) if scalar @_ == 2;
23     return CORE::index($_[0], $_[1], $_[2]);
24 }
25 sub rindex  {
26     return CORE::rindex($_[0], $_[1]) if scalar @_ == 2;
27     return CORE::rindex($_[0], $_[1], $_[2]);
28 }
29 sub split   {
30     return [ CORE::split($_[1], $_[0]) ] if scalar @_ == 2;
31     return [ CORE::split($_[1], $_[0], $_[2]) ];
32 }
33
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;
47   
48   "Hello World"->uc; # HELLO WORLD
49
50 =head1 DESCRIPTION
51
52 This is a role to describes a String value.
53
54 =head1 METHODS
55
56 =over 4
57
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
72 =item B<rindex>
73
74 =item B<uc>
75
76 =item B<ucfirst>
77
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
90 =back
91
92 =over 4
93
94 =item B<meta>
95
96 =back
97
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
110 Copyright 2006-2008 by Infinity Interactive, Inc.
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
117 =cut
118