Class: Kamelopard::Orientation

Inherits:
Object
  • Object
show all
Defined in:
lib/kamelopard/classes.rb

Overview

Sub-object in the KML Model class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(heading, tilt, roll) ⇒ Orientation

Returns a new instance of Orientation.



2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
# File 'lib/kamelopard/classes.rb', line 2254

def initialize(heading, tilt, roll)
    @heading = heading
    # Although the KML reference by Google is clear on these ranges, Google Earth
    # supports values outside the ranges, and sometimes it's useful to use
    # them. So I'm turning off this error checking
    #raise "Heading should be between 0 and 360 inclusive; you gave #{ heading }" unless @heading <= 360 and @heading >= 0
    @tilt = tilt
    #raise "Tilt should be between 0 and 180 inclusive; you gave #{ tilt }" unless @tilt <= 180 and @tilt >= 0
    @roll = roll
    #raise "Roll should be between 0 and 180 inclusive; you gave #{ roll }" unless @roll <= 180 and @roll >= 0
end

Instance Attribute Details

#headingObject

Returns the value of attribute heading.



2253
2254
2255
# File 'lib/kamelopard/classes.rb', line 2253

def heading
  @heading
end

#rollObject

Returns the value of attribute roll.



2253
2254
2255
# File 'lib/kamelopard/classes.rb', line 2253

def roll
  @roll
end

#tiltObject

Returns the value of attribute tilt.



2253
2254
2255
# File 'lib/kamelopard/classes.rb', line 2253

def tilt
  @tilt
end

Instance Method Details

#to_kml(elem = nil) ⇒ Object



2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
# File 'lib/kamelopard/classes.rb', line 2266

def to_kml(elem = nil)
    x = XML::Node.new 'Orientation'
    {
        :heading => @heading,
        :tilt => @tilt,
        :roll => @roll
    }.each do |k, v|
        d = XML::Node.new k.to_s
        d << v.to_s
        x << d
    end
    elem << x unless elem.nil?
    x
end