mightystring 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mightystring/string.rb +10 -0
- data/lib/mightystring/version.rb +1 -1
- data/test/mightystring_test.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778bad759d8938a1f6a67ecca16a8e1016f88b41
|
4
|
+
data.tar.gz: b12ceac938212db7f5148627a6bc0e5fe5ccd13b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a883bdb80b551896531e020502e51ca59d15d4b3b7e5c2fe1840ec9c9dbd0bc0e6196d1338a4462504e3bda50c6f64b11acbe23328415a69a7d6f91ec76dfad
|
7
|
+
data.tar.gz: 1c4f748d92eb47bf14df9c799c442f286de0981d59eb0a9f450206054bd2d8b072b92a11f044c8ea450268c043c749f5cf691f3b44bcdec5f27999cefdfb9649
|
data/lib/mightystring/string.rb
CHANGED
@@ -5,6 +5,8 @@ module MightyString
|
|
5
5
|
def self.included(base)
|
6
6
|
base.class_eval {
|
7
7
|
alias_method :at, :[]
|
8
|
+
alias_method :bhead, :bisect_head
|
9
|
+
alias_method :btail, :bisect_tail
|
8
10
|
|
9
11
|
extend Forwardable
|
10
12
|
def_delegators :chars, :first, :last, :values_at
|
@@ -31,6 +33,10 @@ module MightyString
|
|
31
33
|
self[0...offset]
|
32
34
|
end
|
33
35
|
|
36
|
+
def bisect_head offset = 1
|
37
|
+
[head(offset), tail(offset)]
|
38
|
+
end
|
39
|
+
|
34
40
|
def index_all matcher
|
35
41
|
arr_indexes = []
|
36
42
|
srch_index = rindex(matcher)
|
@@ -83,6 +89,10 @@ module MightyString
|
|
83
89
|
self[offset..-1]
|
84
90
|
end
|
85
91
|
|
92
|
+
def bisect_tail offset = 1
|
93
|
+
[tail(offset), head(offset)]
|
94
|
+
end
|
95
|
+
|
86
96
|
def unshift str
|
87
97
|
replace str.+(self)
|
88
98
|
end
|
data/lib/mightystring/version.rb
CHANGED
data/test/mightystring_test.rb
CHANGED
@@ -47,6 +47,20 @@ describe MightyString do
|
|
47
47
|
_("asdf".tail(3)).must_equal "f"
|
48
48
|
end
|
49
49
|
|
50
|
+
it "String#bisect_head and String#head_" do
|
51
|
+
_("asdf".bisect_head).must_equal ["a", "sdf"]
|
52
|
+
_("asdf".bisect_head(3)).must_equal ["asd", "f"]
|
53
|
+
_("asdf".bhead).must_equal ["a", "sdf"]
|
54
|
+
_("asdf".bhead(3)).must_equal ["asd", "f"]
|
55
|
+
end
|
56
|
+
|
57
|
+
it "String#bisect_tail and String#tail_" do
|
58
|
+
_("asdf".bisect_tail).must_equal ["sdf", "a"]
|
59
|
+
_("asdf".bisect_tail(3)).must_equal ["f", "asd"]
|
60
|
+
_("asdf".btail).must_equal ["sdf", "a"]
|
61
|
+
_("asdf".btail(3)).must_equal ["f", "asd"]
|
62
|
+
end
|
63
|
+
|
50
64
|
it "sorts" do
|
51
65
|
str = "asdf"
|
52
66
|
_(str.sort).must_equal "adfs"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mightystring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark / 6ftDan(TM)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02
|
11
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|