Class: Resolv::DNS::Resource::LOC

Inherits:
Resource
  • Object
show all
Defined in:
lib/resolv.rb

Overview

Location resource

Constant Summary collapse

TypeValue =

:nodoc:

29

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LOC.



2581
2582
2583
2584
2585
2586
2587
2588
2589
# File 'lib/resolv.rb', line 2581

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



2632
2633
2634
# File 'lib/resolv.rb', line 2632

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



2607
2608
2609
# File 'lib/resolv.rb', line 2607

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



2620
2621
2622
# File 'lib/resolv.rb', line 2620

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



2626
2627
2628
# File 'lib/resolv.rb', line 2626

def longitude
  @longitude
end

#ssizeObject (readonly)

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



2600
2601
2602
# File 'lib/resolv.rb', line 2600

def ssize
  @ssize
end

#versionObject (readonly)

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



2594
2595
2596
# File 'lib/resolv.rb', line 2594

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



2614
2615
2616
# File 'lib/resolv.rb', line 2614

def vprecision
  @vprecision
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc:



2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
# File 'lib/resolv.rb', line 2644

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:



2634
2635
2636
2637
2638
2639
2640
2641
2642
# File 'lib/resolv.rb', line 2634

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