summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Mackintosh <m@zyp.io>2015-01-26 16:38:10 -0500
committerMike Mackintosh <m@zyp.io>2015-01-26 16:38:10 -0500
commitc635c994d1b1725f2b6994e6538a33f0bf8c92e8 (patch)
treefc0162889fe2a9f743afaa95af1675acbe4b5391 /lib
parent35af5ddc8f602ba2cdde1c72b70c92c0f19548cb (diff)
downloadipaddress-c635c994d1b1725f2b6994e6538a33f0bf8c92e8.tar.gz
use the #to_ipv6 method, faster
Diffstat (limited to 'lib')
-rw-r--r--lib/ipaddress/ipv4.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb
index 0cb30ab..a32a4a0 100644
--- a/lib/ipaddress/ipv4.rb
+++ b/lib/ipaddress/ipv4.rb
@@ -239,9 +239,8 @@ module IPAddress;
# ip.to_h
# #=> 0a000000
#
- def hex
- hex = @octets.map{|o| o.to_s(16).rjust(2, '0') }.join()
- "#{hex}"
+ def hex(space=true)
+ "%.4x%.4x" % [to_u32].pack("N").unpack("nn")
end
alias_method :to_h, :hex
alias_method :to_hex, :hex