Class: Gem::Resolv::LOC::Size
- Inherits:
-
Object
- Object
- Gem::Resolv::LOC::Size
- Defined in:
- lib/rubygems/vendor/resolv/lib/resolv.rb
Overview
A Gem::Resolv::LOC::Size
Constant Summary collapse
- Regex =
Regular expression LOC size must match.
/^(\d+\.*\d*)[m]$/
Instance Attribute Summary collapse
-
#scalar ⇒ Object
readonly
The raw size.
Class Method Summary collapse
-
.create(arg) ⇒ Object
Creates a new LOC::Size from
argwhich may be:.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#eql?(other) ⇒ Boolean
:nodoc:.
-
#hash ⇒ Object
:nodoc:.
-
#initialize(scalar) ⇒ Size
constructor
Internal use; use self.create.
-
#inspect ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(scalar) ⇒ Size
Internal use; use self.create.
3288 3289 3290 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3288 def initialize(scalar) @scalar = scalar end |
Instance Attribute Details
#scalar ⇒ Object (readonly)
The raw size
3295 3296 3297 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3295 def scalar @scalar end |
Class Method Details
.create(arg) ⇒ Object
Creates a new LOC::Size from arg which may be:
- LOC::Size
-
returns
arg. - String
-
argmust match the LOC::Size::Regex constant
3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3270 def self.create(arg) case arg when Size return arg when String scalar = '' if Regex =~ arg scalar = [(($1.to_f*(1e2)).to_i.to_s[0].to_i*(2**4)+(($1.to_f*(1e2)).to_i.to_s.length-1))].pack("C") else raise ArgumentError.new("not a properly formed Size string: " + arg) end return Size.new(scalar) else raise ArgumentError.new("cannot interpret as Size: #{arg.inspect}") end end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
3306 3307 3308 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3306 def ==(other) # :nodoc: return @scalar == other.scalar end |
#eql?(other) ⇒ Boolean
:nodoc:
3310 3311 3312 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3310 def eql?(other) # :nodoc: return self == other end |
#hash ⇒ Object
:nodoc:
3314 3315 3316 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3314 def hash # :nodoc: return @scalar.hash end |
#inspect ⇒ Object
:nodoc:
3302 3303 3304 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3302 def inspect # :nodoc: return "#<#{self.class} #{self}>" end |
#to_s ⇒ Object
:nodoc:
3297 3298 3299 3300 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3297 def to_s # :nodoc: s = @scalar.unpack("H2").join.to_s return ((s[0].to_i)*(10**(s[1].to_i-2))).to_s << "m" end |