ip 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/ip.rb +2 -3
  2. data/lib/ip/address.rb +18 -4
  3. metadata +2 -2
data/lib/ip.rb CHANGED
@@ -78,10 +78,9 @@ class IP
78
78
 
79
79
  end
80
80
 
81
- $:.unshift(File.dirname(__FILE__))
81
+ $:.push(File.dirname(__FILE__))
82
82
  require 'ip/address'
83
83
  require 'ip/cidr'
84
84
  require 'ip/range'
85
85
  require 'ip/util'
86
- $:.shift
87
-
86
+ $:.pop
@@ -43,6 +43,13 @@ end
43
43
  #
44
44
 
45
45
  class IP::Address::IPv4 < IP::Address
46
+ #
47
+ # Parses an IP address and stores it as the current address
48
+ #
49
+ def IPv4.parse(ip_address)
50
+ return IP::Address::IPv4.new(ip_address)
51
+ end
52
+
46
53
  #
47
54
  # Constructs an IP::Address::IPv4 object.
48
55
  #
@@ -153,11 +160,10 @@ class IP::Address::IPv6 < IP::Address
153
160
  end
154
161
 
155
162
  @ip_address = ip_address
156
-
163
+
157
164
  octets = parse_address(ip_address)
158
-
165
+
159
166
  if octets.length != 8
160
- puts octets
161
167
  raise IP::AddressException.new("IPv6 address '#{ip_address}' does not have 8 octets or a floating range specifier")
162
168
  end
163
169
 
@@ -169,6 +175,14 @@ class IP::Address::IPv6 < IP::Address
169
175
  @octets = octets_atoi(octets)
170
176
  end
171
177
 
178
+ #
179
+ # parses an ip address and stores it as the current object.
180
+ #
181
+
182
+ def IPv6.parse(ip_address)
183
+ return IP::Address::IPv6.new(ip_address)
184
+ end
185
+
172
186
  #
173
187
  # returns an octet in its hexidecimal representation.
174
188
  #
@@ -242,7 +256,7 @@ class IP::Address::IPv6 < IP::Address
242
256
  def pack
243
257
  return IP::Address::Util.raw_pack(self.octets.dup)
244
258
  end
245
-
259
+
246
260
  protected
247
261
 
248
262
  #
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: ip
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.0
7
- date: 2006-03-19 00:00:00 -08:00
6
+ version: 0.2.1
7
+ date: 2006-04-20 00:00:00 -07:00
8
8
  summary: Ruby classes to work with IP address, ranges, and netmasks
9
9
  require_paths:
10
10
  - lib