mightystring 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2c6db7592a53f3b0b8da6aad7805996123c093d
4
- data.tar.gz: 5fc669e5824168df43677c94810d259173b82d17
3
+ metadata.gz: 778bad759d8938a1f6a67ecca16a8e1016f88b41
4
+ data.tar.gz: b12ceac938212db7f5148627a6bc0e5fe5ccd13b
5
5
  SHA512:
6
- metadata.gz: e7183e152148b74707088434bb0c4a66be906b40a213d1903155679a41ff41e9d01d2a98024d2e12a4677d6d47585c93e3ed445f019d00a580f6f769dbe009bc
7
- data.tar.gz: db097d0fe3c382ea1548eb88dde6262781993ae7e2ee27cf369267cd204a1c2d4f81dfb78a9d8f63f2442af8081166492ae57d24cc1908e25bfe9c0a2dda8305
6
+ metadata.gz: 9a883bdb80b551896531e020502e51ca59d15d4b3b7e5c2fe1840ec9c9dbd0bc0e6196d1338a4462504e3bda50c6f64b11acbe23328415a69a7d6f91ec76dfad
7
+ data.tar.gz: 1c4f748d92eb47bf14df9c799c442f286de0981d59eb0a9f450206054bd2d8b072b92a11f044c8ea450268c043c749f5cf691f3b44bcdec5f27999cefdfb9649
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MightyString
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -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.1
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-25 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler