Class: 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 KMLObject

#comment, #id

Instance Method Summary collapse

Constructor Details

#initialize(updates = [], duration = 0, target = '', delayedstart = nil) ⇒ AnimatedUpdate

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



1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
# File 'lib/kamelopard/classes.rb', line 1180

def initialize(updates = [], duration = 0, target = '', delayedstart = nil)
    super()
    begin
        raise "incorrect object type" unless @target.kind_of? KMLObject
        @target = target.id
    rescue RuntimeError
        @target = target
    end
    @updates = updates
    @duration = duration
    @delayedstart = delayedstart
end

Instance Attribute Details

#delayedstartObject

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



1177
1178
1179
# File 'lib/kamelopard/classes.rb', line 1177

def delayedstart
  @delayedstart
end

#durationObject

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



1177
1178
1179
# File 'lib/kamelopard/classes.rb', line 1177

def duration
  @duration
end

#targetObject

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



1177
1178
1179
# File 'lib/kamelopard/classes.rb', line 1177

def target
  @target
end

#updatesObject

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



1177
1178
1179
# File 'lib/kamelopard/classes.rb', line 1177

def updates
  @updates
end

Instance Method Details

#<<(a) ⇒ Object

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



1194
1195
1196
# File 'lib/kamelopard/classes.rb', line 1194

def <<(a)
    @updates << a << "\n"
end

#to_kml(indent = 0) ⇒ Object



1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
# File 'lib/kamelopard/classes.rb', line 1198

def to_kml(indent = 0)
    k = super + <<-animatedupdate_kml
#{ ' ' * indent }<gx:AnimatedUpdate>
#{ ' ' * indent }    <gx:duration>#{@duration}</gx:duration>
    animatedupdate_kml
    k << "#{ ' ' * indent }    <gx:delayeStart>#{@delayedstart}</gx:delayedStart>\n" unless @delayedstart.nil?
    k << "#{ ' ' * indent }    <Update>\n"
    k << "#{ ' ' * indent }        <targetHref>#{@target}</targetHref>\n"
    k << "#{ ' ' * indent }        " << @updates.join("\n#{ ' ' * (indent + 1) }")
    k << "#{ ' ' * indent }    </Update>\n#{ ' ' * indent }</gx:AnimatedUpdate>\n"
    k
end