blob: 9b5266c58c79b3052076585fbc04578316381dec (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
require "active_support/multibyte"
class String
def at(position)
self[position]
end
def from(position)
self[position..-1]
end
def to(position)
self[0..position]
end
def first(limit = 1)
if limit == 0
''
elsif limit >= size
self
else
to(limit - 1)
end
end
def last(limit = 1)
if limit == 0
''
elsif limit >= size
self
else
from(-limit)
end
end
end
|