embrace 1.2.2 → 1.2.3

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: 44b84935504ec153e647b337c9e3ad22ac86cc6f
4
- data.tar.gz: baf85efaea3fef4d0c82d30bf3eccde326646c80
3
+ metadata.gz: dae26e29a55be3acf9f332a29efe864b7e4229f2
4
+ data.tar.gz: ff87e70520367861480d49a0819b2cf82676e18f
5
5
  SHA512:
6
- metadata.gz: df626da34b508b36edc08e04df42192ae7015c859be88b750d253d20afb3e9ea2c847973a18b70d1fa60c154bfad53bc1b433b3dad7cd783a622a92924fe1592
7
- data.tar.gz: 3ac6958161038ebb0c243afe2da1078b00802fcca410fea506a3b4a1048a23f9520d4a2e0fc07cdddf92fb3be334ac439d3c5b788f1b857534a137e3bd0ca7f7
6
+ metadata.gz: abc92d9bcca9a57f95bc71241bdb0595a6f09945a4badf9b9d3fcfbff23de380e5495427a42d822b08f1d883556cb42fa4faf6c8168dd1623ef9867dd318b096
7
+ data.tar.gz: 68a3e6165980cb667a62c5bc743bc60195bdd6c4776fa6b50a9387be5e0b1b3d78b7e723693888084ad3f81d827c074abd654ea656ff8d3917f3e8957e244bab
@@ -1,39 +1,27 @@
1
1
  require "embrace"
2
2
 
3
3
  module Embrace
4
- class Brackets < Proc
5
- class << self
6
- def new(opening, closing)
7
- super(&(->(text) { "#{opening}#{text}#{closing}" }))
8
- end
4
+ module Brackets
5
+ module_function
9
6
 
10
- def from_str(style)
11
- i = style.size / 2
12
- new(style[0...i], style[i..-1])
13
- end
7
+ def from_brackets(opening, closing)
8
+ ->(text) { "#{opening}#{text}#{closing}" }
14
9
  end
15
10
 
16
- def to_ary
17
- bracketed = self["a"]
18
- index = bracketed.chars.zip(self["b"].chars).find_index { |a, b| a != b }
19
- [ bracketed[0...index], bracketed[(index + 1)..-1] ]
20
- end
21
-
22
- alias_method :to_a, :to_ary
23
-
24
- def inspect
25
- "#<Brackets style=#{to_a.join('').inspect}>"
11
+ def from_str(style)
12
+ i = style.size / 2
13
+ from_brackets(style[0...i], style[i..-1])
26
14
  end
27
15
  end
28
16
 
29
17
  module_function
30
18
 
31
19
  def Brackets(style_or_opening, *closing)
32
- return Brackets.new(style_or_opening, *closing) unless closing.empty?
20
+ return Brackets.from_brackets(style_or_opening, *closing) unless closing.empty?
33
21
 
34
22
  case style_or_opening
35
- when Brackets then style_or_opening
36
- when Array then Brackets.new(*style_or_opening)
23
+ when Proc then style_or_opening
24
+ when Array then Brackets.from_brackets(*style_or_opening)
37
25
  else
38
26
  Brackets.from_str(style_or_opening.to_s)
39
27
  end
@@ -1,3 +1,3 @@
1
1
  module Embrace
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Carney