bithex 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/bithex/type.rb +10 -2
- data/lib/bithex/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fe743fb9d20b3f4dc702db5622b4c71f58ad09f1ce8e52d060b10f83d6becd8
|
4
|
+
data.tar.gz: '090a8a3ee36b65cb35a70e73932fa15447d02a334895f8161c9d859f4fabc7d3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a8fac6a3104f7dc9d557a592405e67d32b29176b7975e3fe7a8a180877e6f813d4c6017db966632a825275d0997dc90c6a2ce92079250c1af2d2b24de1428b
|
7
|
+
data.tar.gz: e9b65ceb8881f735cbae2d324bb6c1b92e3224e657ee6eb0e2c28cfbe30e9220b7e1c3cc09d26e9c0eac62950c14ecea5c7d36c72735fcec6b285aa72771b442
|
data/README.md
CHANGED
data/lib/bithex/type.rb
CHANGED
@@ -10,18 +10,26 @@ module Bithex
|
|
10
10
|
validate_subtype
|
11
11
|
end
|
12
12
|
|
13
|
+
def type
|
14
|
+
:bithex
|
15
|
+
end
|
16
|
+
|
13
17
|
def deserialize(value)
|
14
18
|
return if value.blank?
|
15
19
|
|
16
20
|
format("%0#{hex_value_length}x", value.to_i(2))
|
17
21
|
end
|
18
22
|
|
23
|
+
alias type_cast_from_database deserialize
|
24
|
+
|
19
25
|
def serialize(value)
|
20
26
|
return if value.blank?
|
21
27
|
|
22
|
-
[value.to_s].pack('H*').
|
28
|
+
[value.to_s].pack('H*').unpack('B*')[0]
|
23
29
|
end
|
24
30
|
|
31
|
+
alias type_cast_for_database serialize
|
32
|
+
|
25
33
|
def assert_valid_value(value)
|
26
34
|
return if value.blank?
|
27
35
|
|
@@ -43,7 +51,7 @@ module Bithex
|
|
43
51
|
end
|
44
52
|
|
45
53
|
def validate_format(value)
|
46
|
-
return if value
|
54
|
+
return if value =~ /\h+/
|
47
55
|
|
48
56
|
raise ArgumentError,
|
49
57
|
"Expected '#{value}' to be a hex string"
|
data/lib/bithex/version.rb
CHANGED