Class: Kamelopard::Orientation
- Inherits:
-
Object
- Object
- Kamelopard::Orientation
- Defined in:
- lib/kamelopard/classes.rb
Overview
Sub-object in the KML Model class
Instance Attribute Summary collapse
-
#heading ⇒ Object
Returns the value of attribute heading.
-
#roll ⇒ Object
Returns the value of attribute roll.
-
#tilt ⇒ Object
Returns the value of attribute tilt.
Instance Method Summary collapse
-
#initialize(heading, tilt, roll) ⇒ Orientation
constructor
A new instance of Orientation.
- #to_kml(elem = nil) ⇒ Object
Constructor Details
#initialize(heading, tilt, roll) ⇒ Orientation
Returns a new instance of Orientation.
2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 |
# File 'lib/kamelopard/classes.rb', line 2314 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
#heading ⇒ Object
Returns the value of attribute heading.
2313 2314 2315 |
# File 'lib/kamelopard/classes.rb', line 2313 def heading @heading end |
#roll ⇒ Object
Returns the value of attribute roll.
2313 2314 2315 |
# File 'lib/kamelopard/classes.rb', line 2313 def roll @roll end |
#tilt ⇒ Object
Returns the value of attribute tilt.
2313 2314 2315 |
# File 'lib/kamelopard/classes.rb', line 2313 def tilt @tilt end |
Instance Method Details
#to_kml(elem = nil) ⇒ Object
2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 |
# File 'lib/kamelopard/classes.rb', line 2326 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 |