Class: Resolv::LOC::Size
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/resolv.rb |
Overview
A Size
Constant Summary
-
Regex =
# File 'lib/resolv.rb', line 3262
Regular expression
::Resolv::LOCsize must match./^(\d+\.*\d*)[m]$/
Class Method Summary
-
.create(arg)
Creates a new
Sizefromargwhich may be: -
.new(scalar) ⇒ Size
constructor
Internal use; use self.create.
Instance Attribute Summary
-
#scalar
readonly
The raw size.
Instance Method Summary
Constructor Details
.new(scalar) ⇒ Size
Internal use; use self.create.
Class Method Details
.create(arg)
Creates a new Size from arg which may be:
- LOC::Size
-
returns
arg. - String
-
argmust match the Regex constant
# File '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 Attribute Details
#scalar (readonly)
The raw size
# File 'lib/resolv.rb', line 3295
attr_reader :scalar
Instance Method Details
#==(other)
[ GitHub ]# File 'lib/resolv.rb', line 3306
def ==(other) # :nodoc: return @scalar == other.scalar end
#eql?(other) ⇒ Boolean
# File 'lib/resolv.rb', line 3310
def eql?(other) # :nodoc: return self == other end
#hash
[ GitHub ]# File 'lib/resolv.rb', line 3314
def hash # :nodoc: return @scalar.hash end
#inspect
[ GitHub ]# File 'lib/resolv.rb', line 3302
def inspect # :nodoc: return "#<#{self.class} #{self}>" end
#to_s
[ GitHub ]# File '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