ip2dword 0.1.1

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +5 -0
  3. data/lib/ip2dword.rb +13 -0
  4. metadata +46 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57070bc2d41bf96b74aa9cc5293084a9c9085603
4
+ data.tar.gz: 1d48bf9a6b338d88c53fde6bd9a02000ecc7349d
5
+ SHA512:
6
+ metadata.gz: 122b3b6a5ddae3114bcba2b7fcd339d7341e6d53bdef9fe7e4afdcb2bdb843c7fc0c541fc739052a9675f5c4b7fca167a852be86f6ade8461b01c5f9367ac24a
7
+ data.tar.gz: e8473973556fb87f34294a8bb1c6f32f318847118db755dd366f6df22f70df3670c2dafd9f274084c27bd4014f1574f60cf4a0be48362a505eaab27c309d61ba
@@ -0,0 +1,5 @@
1
+ ```
2
+ require "ip2word"
3
+ p IP2dword.convert("192.168.1.1")
4
+ {"dec"=>"3232235777", "oct"=>"30052000401", "hex"=>"c0a80101"}
5
+ ```
@@ -0,0 +1,13 @@
1
+ require "ipaddr"
2
+ class IP2dword
3
+ def self.convert(ip)
4
+ return "Invalid IP" if (IPAddr.new(ip) rescue nil).nil?
5
+ a, b, c, d = ip.split('.').map(&:to_i)
6
+ i = a * 256**3 + b * 256**2 + c * 256 + d
7
+ return {
8
+ "dec" => i.to_s,
9
+ "oct" => i.to_s(8),
10
+ "hex" => i.to_s(16)
11
+ }
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ip2dword
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Hemanth.HM
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Converts IP to ip2dword
14
+ email: hemanth.hm@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files:
18
+ - README.md
19
+ files:
20
+ - lib/ip2dword.rb
21
+ - README.md
22
+ homepage: http://h3manth.com
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 1.3.6
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.1.9
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: ip2dword
46
+ test_files: []