bindata-contrib 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f24245c18ea4e764422c520309e2d492ce57f595
4
- data.tar.gz: f36c9fbcebd5bce5e8414ff2eaf8f82880fe65bf
3
+ metadata.gz: 65ff9df3a36760b71ea916558e41c34039d787a7
4
+ data.tar.gz: 331a505e228bd5b26e0ec820c96e6b73239a2c5f
5
5
  SHA512:
6
- metadata.gz: 00bba4729d535d5f85dc7d19e9e3a3da06ac6fb5026a98431965b2f5f9b190ce716e2669e3b23c0ab14a6a9f5b806df3f9cf0671573cae62779a04f7df695c82
7
- data.tar.gz: 2dc5d7831a7de89358007aafcc0c4fe5f889e2d040f44e0200ed0ed45df2ae03c2aa3bb7408ac796603c2954c455f77264697a3baa9542eb3987edd7507b4a4c
6
+ metadata.gz: 2d8dfa470db358f55bb0510c140e2051a50de7bc8a603b870e2ed68902278492967ca4bd96fa921e4d7db8eab5973b1d08acf8422f9ad3d0d7124a812deb7a48
7
+ data.tar.gz: fd051a5cc275a742693dedf37330ef11c1b556a7965e3d5ca894008f87a531b79e41d0c3c0fd4218433687fbb8b62e69c8314207ac23bc57219f3f37841d1056
@@ -1,3 +1,6 @@
1
1
  require_relative 'bool'
2
2
  require_relative 'enum'
3
3
  require_relative 'flags'
4
+ require_relative 'mac_address'
5
+ require_relative 'ipv4_address'
6
+ require_relative 'ipv6_address'
@@ -0,0 +1,14 @@
1
+ require 'bindata'
2
+
3
+ class Ipv4Address < BinData::Primitive
4
+ endian :big
5
+ array :octets, type: :uint8, initial_length: 4
6
+
7
+ def get
8
+ octets.map(&:to_s).join('.')
9
+ end
10
+
11
+ def set(value)
12
+ self.octets = value.split('.').map(&:to_i)
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'bindata'
2
+
3
+ class Ipv6Address < BinData::Primitive
4
+ endian :big
5
+ array :octets, type: :uint8, initial_length: 16
6
+
7
+ def get
8
+ octets.map { |o| o.to_s(16) }.join(':')
9
+ end
10
+
11
+ def set(value)
12
+ self.octets = value.split(':').map { |o| o.to_i(16) }
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'bindata'
2
+
3
+ class MacAddress < BinData::Primitive
4
+ endian :big
5
+ array :octets, type: :uint8, initial_length: 6
6
+
7
+ def get
8
+ octets.map { |octet| format('%02x', octet) }.join(':')
9
+ end
10
+
11
+ def set(value)
12
+ self.octets = value.split(':').map(&:hex)
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindata-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy Pagé
@@ -21,6 +21,9 @@ files:
21
21
  - lib/bool.rb
22
22
  - lib/enum.rb
23
23
  - lib/flags.rb
24
+ - lib/ipv4_address.rb
25
+ - lib/ipv6_address.rb
26
+ - lib/mac_address.rb
24
27
  homepage: https://github.com/jejepage/bindata-contrib
25
28
  licenses:
26
29
  - MIT
@@ -44,5 +47,5 @@ rubyforge_project:
44
47
  rubygems_version: 2.4.8
45
48
  signing_key:
46
49
  specification_version: 4
47
- summary: BinData Contrub
50
+ summary: BinData Contrib
48
51
  test_files: []