class Resolv::LOC::Size - Documentation for Ruby 4.1
Description: class Resolv::LOC::Size: A Resolv::LOC::Size
Keywords: ruby,class,Resolv::LOC::Size

🔍

No recent searches

# class Resolv::LOC::Size

A `Resolv::LOC::Size`

### Constants

Regex

  Regular expression `LOC` size must match.

### Attributes

scalar [R]

The raw size

### Public Class Methods

create (arg)
Source

    # File lib/resolv.rb, line 3279
    def self.create(arg)
      case arg
      when Size
        return arg
      when String
        unless Regex =~ arg
          raise ArgumentError.new("not a properly formed Size string: " + arg)
        end
        unless (0.0...1e8) === (scalar = $1.to_f)
          raise ArgumentError.new("out of range as Size: #{arg}")
        end
        str = (scalar * 100).to_i.to_s
        return new([(str[0].to_i << 4) + (str.bytesize-1)].pack("C"))
      else
        raise ArgumentError.new("cannot interpret as Size: #{arg.inspect}")
      end
    end

Creates a new `LOC::Size` from `arg` which may be:

`LOC::Size`

  returns `arg`.

`String`

  `arg` must match the `LOC::Size::Regex` constant

new (scalar)
Source

    # File lib/resolv.rb, line 3298
    def initialize(scalar)
      @scalar = scalar
    end

Internal use; use self.create.