embrace 1.2.0 → 1.2.1
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 +9 -11
- 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: 2151d5d0fb534964eea78de0ca65bc95f8f9d4ef
|
4
|
+
data.tar.gz: 6b4e80a69b7c2493c7b3de23a952868886fb7edf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c908ce4f147a0ba55e1dcc5122a7f2ba521e48f04cb0b72f87b0509069da255358e1d25fe4c5b75b2aa93572f43cbbb986b2edd52202493fe77a42d424605226
|
7
|
+
data.tar.gz: 23aa76aa0e5ade03f8a45f12ca4033af50c9ead5788f070eb0d3d8cb577b2f8d63abb27fe6e3997438953f5aa3b7e118c04ab22888dbd0d7dc354d82675ab5fb
|
data/lib/embrace/brackets.rb
CHANGED
@@ -3,15 +3,13 @@ require "embrace"
|
|
3
3
|
module Embrace
|
4
4
|
class Brackets < Proc
|
5
5
|
class << self
|
6
|
-
def
|
7
|
-
|
8
|
-
"#{opening}#{text}#{closing}"
|
9
|
-
end
|
6
|
+
def new(opening, closing)
|
7
|
+
super(&(->(text) { "#{opening}#{text}#{closing}" }))
|
10
8
|
end
|
11
9
|
|
12
10
|
def from_str(style)
|
13
11
|
i = style.size / 2
|
14
|
-
|
12
|
+
new(style[0...i], style[i..-1])
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
@@ -30,14 +28,14 @@ module Embrace
|
|
30
28
|
|
31
29
|
module_function
|
32
30
|
|
33
|
-
def Brackets(
|
34
|
-
return Brackets.
|
31
|
+
def Brackets(style_or_opening, *closing)
|
32
|
+
return Brackets.new(style_or_opening.to_s, *closing.map(&:to_s)) unless closing.empty?
|
35
33
|
|
36
|
-
case
|
37
|
-
when Brackets then
|
38
|
-
when Array then Brackets(*
|
34
|
+
case style_or_opening
|
35
|
+
when Brackets then style_or_opening
|
36
|
+
when Array then Brackets(*style_or_opening)
|
39
37
|
else
|
40
|
-
Brackets.from_str(
|
38
|
+
Brackets.from_str(style_or_opening.to_s)
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
data/lib/embrace/version.rb
CHANGED