iostruct 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a17b782202e0503788fd3b16dffdebddecd62becb30c52ba28161ebde1e300d
4
- data.tar.gz: d42484281a468a378902d4589b67201ad4f134660559766690e48849b9f2a46c
3
+ metadata.gz: 0376aab4653f3f1fb656d82f679346bd1d04c6d8f80e17540a4a7fbb3bc470d7
4
+ data.tar.gz: 211894d68015bc52658e8e818296a42c115bdeda8cfa2cb6525cadb1e9554e9b
5
5
  SHA512:
6
- metadata.gz: db34080f66b2815628e20a6e7b9331089d55a011dd35ae90b9e8f7758cb97332fad7b9caadfcc977a93e104cb0d9b9e3c932e82a2070e54205ba3bb7a52337d4
7
- data.tar.gz: d25f3804da77a52630bb4492548c3ab71124c06610558dde277ea2c769a826ce8a720a5df99b2ab3691791b090f6ec4774b65e8072117383ab389e4095451a0f
6
+ metadata.gz: 79edc6088c3258506085cf22aee37e75386bab8309c478786ec3022f3895f34a4b05490640bca22db56b78242b500d7030d3fc6b141a24aa0f9cfc1681baef7d
7
+ data.tar.gz: 36ddc86813c0c0fc92874025fbe37f755a8f1cef22533949b101428b50ca2a0369aae9beddfe99a4b00d71c0db5985ec4f89b5beddefcc262ea6c91dfd2787b7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 0.4.0
2
+
3
+ - added `size` class method that returns SIZE constant
4
+
5
+ ```ruby
6
+ X = IOStruct.new('LL')
7
+ X::SIZE # 8
8
+ X.size # 8
9
+ ```
10
+
1
11
  # 0.3.0
2
12
 
3
13
  - added `__offset` field:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IOStruct
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/iostruct.rb CHANGED
@@ -110,6 +110,10 @@ module IOStruct
110
110
  # end
111
111
  new(*data.unpack(const_get('FORMAT'))).tap{ |x| x.__offset = pos }
112
112
  end
113
+
114
+ def size
115
+ self::SIZE
116
+ end
113
117
  end # ClassMethods
114
118
 
115
119
  module InstanceMethods
@@ -36,10 +36,14 @@ describe IOStruct do
36
36
  expect(x.c).to eq 2
37
37
  end
38
38
 
39
- it "has correct size" do
39
+ it "has correct SIZE" do
40
40
  expect(struct::SIZE).to eq 2
41
41
  end
42
42
 
43
+ it "has correct size" do
44
+ expect(struct.size).to eq 2
45
+ end
46
+
43
47
  it "reads correct number of bytes from IO" do
44
48
  io = StringIO.new(data*2)
45
49
  x = struct.read(io)
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey "Zed" Zaikin