iostruct 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/iostruct/version.rb +1 -1
- data/lib/iostruct.rb +17 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 535a978c6d95f5213d7a7e63523b46788adc2d6ca83c714758e9f30f927f546f
|
4
|
+
data.tar.gz: 5f52aea99a2615221a62e9b7d3228f129f1320e2a21c8b65eae3fec644e4007a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a7489c0f185fb36a4e54c51273c2b87bd344754522e6584b329f529ed0ae00c8c287a1abf224b4cd3bfc1ed44fa5694c8036c89b3ef881231f8cfb4f773b6b0
|
7
|
+
data.tar.gz: 4fa626885e4446c846594c1be13b67649928e45e919aabc660cc2c414c7cb225efb29841e5bd856737d905d988f5dd2219dd3c1622c976cb2e656799beb2a0fe
|
data/lib/iostruct/version.rb
CHANGED
data/lib/iostruct.rb
CHANGED
@@ -129,8 +129,18 @@ module IOStruct
|
|
129
129
|
end # InstanceMethods
|
130
130
|
|
131
131
|
module HexInspect
|
132
|
-
def
|
133
|
-
|
132
|
+
def to_s
|
133
|
+
s = "<#{self.class.to_s} " + to_h.map do |k, v|
|
134
|
+
if v.is_a?(Integer) && v > 9
|
135
|
+
"#{k}=0x%x" % v
|
136
|
+
else
|
137
|
+
"#{k}=#{v.inspect}"
|
138
|
+
end
|
139
|
+
end.join(' ') + ">"
|
140
|
+
end
|
141
|
+
|
142
|
+
def to_table
|
143
|
+
@fmtstr_tbl = "<#{self.class.to_s} " + self.class.const_get('FIELDS').map do |name, f|
|
134
144
|
fmt =
|
135
145
|
case
|
136
146
|
when f.type == Integer
|
@@ -142,7 +152,11 @@ module IOStruct
|
|
142
152
|
end
|
143
153
|
"#{name}=#{fmt}"
|
144
154
|
end.join(' ') + ">"
|
145
|
-
sprintf @
|
155
|
+
sprintf @fmtstr_tbl, *to_a.map{ |v| v.is_a?(String) ? v.inspect : v }
|
156
|
+
end
|
157
|
+
|
158
|
+
def inspect
|
159
|
+
to_s
|
146
160
|
end
|
147
161
|
end
|
148
162
|
end # IOStruct
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iostruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey "Zed" Zaikin
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
|
-
rubygems_version: 3.5.
|
92
|
+
rubygems_version: 3.5.3
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: A Struct that can read/write itself from/to IO-like objects
|