Class: Kamelopard::AnimatedUpdate

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

Overview

Corresponds to KML’s gx:AnimatedUpdate object. For now at least, this isn’t very intelligent; you’ve got to manually craft the <Change> tag(s) within the object.

Instance Attribute Summary collapse

Attributes inherited from TourPrimitive

#standalone

Attributes inherited from Object

#comment, #kml_id, #master_only

Instance Method Summary collapse

Methods inherited from Object

#_alternate_to_kml, #change, #master_only?, parse

Constructor Details

#initialize(updates, options = {}) ⇒ AnimatedUpdate

The updates argument is an array of strings containing <Change> elements



1808
1809
1810
1811
1812
1813
# File 'lib/kamelopard/classes.rb', line 1808

def initialize(updates, options = {})
 #duration = 0, target = '', delayedstart = nil)
    @updates = []
    super options
    @updates = updates unless updates.nil? or updates.size == 0
end

Instance Attribute Details

#delayedStartObject

XXX For now, the user has to specify the change / create / delete elements in the <Update> manually, rather than creating objects.



1804
1805
1806
# File 'lib/kamelopard/classes.rb', line 1804

def delayedStart
  @delayedStart
end

#durationObject

XXX For now, the user has to specify the change / create / delete elements in the <Update> manually, rather than creating objects.



1804
1805
1806
# File 'lib/kamelopard/classes.rb', line 1804

def duration
  @duration
end

#targetObject

XXX For now, the user has to specify the change / create / delete elements in the <Update> manually, rather than creating objects.



1804
1805
1806
# File 'lib/kamelopard/classes.rb', line 1804

def target
  @target
end

#updatesObject

Returns the value of attribute updates.



1805
1806
1807
# File 'lib/kamelopard/classes.rb', line 1805

def updates
  @updates
end

Instance Method Details

#<<(a) ⇒ Object

Adds another update string, presumably containing a <Change> element



1828
1829
1830
# File 'lib/kamelopard/classes.rb', line 1828

def <<(a)
    @updates << a
end

#to_kml(elem = nil) ⇒ Object



1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
# File 'lib/kamelopard/classes.rb', line 1832

def to_kml(elem = nil)
    k = XML::Node.new 'gx:AnimatedUpdate'
    super(k)
    d = XML::Node.new 'gx:duration'
    d << @duration.to_s
    k << d
    if not @delayedStart.nil? then
        d = XML::Node.new 'gx:delayedStart'
        d << @delayedStart.to_s
        k << d
    end
    d = XML::Node.new 'Update'
    q = XML::Node.new 'targetHref'
    q << @target.to_s
    d << q
    @updates.each do |i|
        if i.is_a? XML::Node then
            d << i
        else
            parser = reader = XML::Parser.string(i)
            doc = parser.parse
            node = doc.child
            n = node.copy true
            d << n
        end
    end
    k << d
    elem << k unless elem.nil?
    k
end