Class: ResolvFiber::DNS::Resource::LOC

Inherits:
ResolvFiber::DNS::Resource show all
Defined in:
lib/resolv_fiber.rb

Overview

Location resource

Constant Summary collapse

TypeValue =

:nodoc:

29

Constants inherited from ResolvFiber::DNS::Resource

ClassHash, ClassInsensitiveTypes, ClassValue

Instance Attribute Summary collapse

Attributes inherited from ResolvFiber::DNS::Resource

#ttl

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ResolvFiber::DNS::Resource

#==, #eql?, get_class, #hash

Constructor Details

#initialize(version, ssize, hprecision, vprecision, latitude, longitude, altitude) ⇒ LOC

Returns a new instance of LOC.



2074
2075
2076
2077
2078
2079
2080
2081
2082
# File 'lib/resolv_fiber.rb', line 2074

def initialize(version, ssize, hprecision, vprecision, latitude, longitude, altitude)
  @version    = version
  @ssize      = Resolv::LOC::Size.create(ssize)
  @hprecision = Resolv::LOC::Size.create(hprecision)
  @vprecision = Resolv::LOC::Size.create(vprecision)
  @latitude   = Resolv::LOC::Coord.create(latitude)
  @longitude  = Resolv::LOC::Coord.create(longitude)
  @altitude   = Resolv::LOC::Alt.create(altitude)
end

Instance Attribute Details

#altitudeObject (readonly)

The altitude of the LOC above a reference sphere whose surface sits 100km below the WGS84 spheroid in centimeters as an unsigned 32bit integer



2125
2126
2127
# File 'lib/resolv_fiber.rb', line 2125

def altitude
  @altitude
end

#hprecisionObject (readonly)

The horizontal precision using ssize type values in meters using scientific notation as 2 integers of XeY for precision use value/2 e.g. 2m = +/-1m



2100
2101
2102
# File 'lib/resolv_fiber.rb', line 2100

def hprecision
  @hprecision
end

#latitudeObject (readonly)

The latitude for this LOC where 2**31 is the equator in thousandths of an arc second as an unsigned 32bit integer



2113
2114
2115
# File 'lib/resolv_fiber.rb', line 2113

def latitude
  @latitude
end

#longitudeObject (readonly)

The longitude for this LOC where 2**31 is the prime meridian in thousandths of an arc second as an unsigned 32bit integer



2119
2120
2121
# File 'lib/resolv_fiber.rb', line 2119

def longitude
  @longitude
end

#ssizeObject (readonly)

The spherical size of this LOC in meters using scientific notation as 2 integers of XeY



2093
2094
2095
# File 'lib/resolv_fiber.rb', line 2093

def ssize
  @ssize
end

#versionObject (readonly)

Returns the version value for this LOC record which should always be 00



2087
2088
2089
# File 'lib/resolv_fiber.rb', line 2087

def version
  @version
end

#vprecisionObject (readonly)

The vertical precision using ssize type values in meters using scientific notation as 2 integers of XeY for precision use value/2 e.g. 2m = +/-1m



2107
2108
2109
# File 'lib/resolv_fiber.rb', line 2107

def vprecision
  @vprecision
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc:



2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
# File 'lib/resolv_fiber.rb', line 2138

def self.decode_rdata(msg) # :nodoc:
  version    = msg.get_bytes(1)
  ssize      = msg.get_bytes(1)
  hprecision = msg.get_bytes(1)
  vprecision = msg.get_bytes(1)
  latitude   = msg.get_bytes(4)
  longitude  = msg.get_bytes(4)
  altitude   = msg.get_bytes(4)
  return self.new(
    version,
    Resolv::LOC::Size.new(ssize),
    Resolv::LOC::Size.new(hprecision),
    Resolv::LOC::Size.new(vprecision),
    Resolv::LOC::Coord.new(latitude,"lat"),
    Resolv::LOC::Coord.new(longitude,"lon"),
    Resolv::LOC::Alt.new(altitude)
  )
end

Instance Method Details

#encode_rdata(msg) ⇒ Object

:nodoc:



2128
2129
2130
2131
2132
2133
2134
2135
2136
# File 'lib/resolv_fiber.rb', line 2128

def encode_rdata(msg) # :nodoc:
  msg.put_bytes(@version)
  msg.put_bytes(@ssize.scalar)
  msg.put_bytes(@hprecision.scalar)
  msg.put_bytes(@vprecision.scalar)
  msg.put_bytes(@latitude.coordinates)
  msg.put_bytes(@longitude.coordinates)
  msg.put_bytes(@altitude.altitude)
end