123456789_123456789_123456789_123456789_123456789_

Class: Gem::Resolv::LOC::Size

Relationships & Source Files
Inherits: Object
Defined in: lib/rubygems/vendor/resolv/lib/resolv.rb

Overview

A Size

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(scalar) ⇒ Size

[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3236

def initialize(scalar)
  @scalar = scalar
end

Class Method Details

.create(arg)

Creates a new Size from arg which may be:

LOC::Size

returns arg.

String

arg must match the Regex constant

[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3219

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

[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3243

attr_reader :scalar

Instance Method Details

#==(other)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3254

def ==(other) # :nodoc:
  return @scalar == other.scalar
end

#eql?(other) ⇒ Boolean

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3258

def eql?(other) # :nodoc:
  return self == other
end

#hash

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3262

def hash # :nodoc:
  return @scalar.hash
end

#inspect

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3250

def inspect # :nodoc:
  return "#<#{self.class} #{self}>"
end

#to_s

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 3245

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