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 Object

#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



1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
# File 'lib/kamelopard/classes.rb', line 1255

def initialize(updates = [], duration = 0, target = '', delayedstart = nil)
    super()
    begin
        raise "incorrect object type" unless @target.kind_of? Object
        @target = target.id
    rescue RuntimeError
        @target = target
    end
    @updates = updates
    @duration = duration
    @delayedStart = delayedstart
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.



1252
1253
1254
# File 'lib/kamelopard/classes.rb', line 1252

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.



1252
1253
1254
# File 'lib/kamelopard/classes.rb', line 1252

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.



1252
1253
1254
# File 'lib/kamelopard/classes.rb', line 1252

def target
  @target
end

#updatesObject

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



1252
1253
1254
# File 'lib/kamelopard/classes.rb', line 1252

def updates
  @updates
end

Instance Method Details

#<<(a) ⇒ Object

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



1269
1270
1271
# File 'lib/kamelopard/classes.rb', line 1269

def <<(a)
    @updates << REXML::Document.new(a).root
end

#to_kml(elem = nil) ⇒ Object



1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
# File 'lib/kamelopard/classes.rb', line 1273

def to_kml(elem = nil)
    k = REXML::Element.new 'gx:AnimatedUpdate'
    super(k)
    d = REXML::Element.new 'gx:duration'
    d.text = @duration
    k << d
    if not @delayedStart.nil? then
        d = REXML::Element.new 'gx:delayedStart'
        d.text = @delayedStart
        k << d
    end
    d = REXML::Element.new 'Update'
    q = REXML::Element.new 'targetHref'
    q.text = @target
    d << q
    @updates.each do |i| d << i end
    k << d
    elem << k unless elem.nil?
    k
end