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 +4 -4
- data/lib/embrace/brackets.rb +10 -22
- data/lib/embrace/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dae26e29a55be3acf9f332a29efe864b7e4229f2
|
4
|
+
data.tar.gz: ff87e70520367861480d49a0819b2cf82676e18f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abc92d9bcca9a57f95bc71241bdb0595a6f09945a4badf9b9d3fcfbff23de380e5495427a42d822b08f1d883556cb42fa4faf6c8168dd1623ef9867dd318b096
|
7
|
+
data.tar.gz: 68a3e6165980cb667a62c5bc743bc60195bdd6c4776fa6b50a9387be5e0b1b3d78b7e723693888084ad3f81d827c074abd654ea656ff8d3917f3e8957e244bab
|
data/lib/embrace/brackets.rb
CHANGED
@@ -1,39 +1,27 @@
|
|
1
1
|
require "embrace"
|
2
2
|
|
3
3
|
module Embrace
|
4
|
-
|
5
|
-
|
6
|
-
def new(opening, closing)
|
7
|
-
super(&(->(text) { "#{opening}#{text}#{closing}" }))
|
8
|
-
end
|
4
|
+
module Brackets
|
5
|
+
module_function
|
9
6
|
|
10
|
-
|
11
|
-
|
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
|
17
|
-
|
18
|
-
|
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.
|
20
|
+
return Brackets.from_brackets(style_or_opening, *closing) unless closing.empty?
|
33
21
|
|
34
22
|
case style_or_opening
|
35
|
-
when
|
36
|
-
when Array
|
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
|
data/lib/embrace/version.rb
CHANGED