Class: Kamelopard::TimeSpan

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

Overview

Corresponds to KML’s TimeSpan object. @begin and @end must be in a format KML understands.

Instance Attribute Summary collapse

Attributes inherited from Object

#comment, #kml_id

Instance Method Summary collapse

Methods inherited from Object

#change

Constructor Details

#initialize(ts_begin = nil, ts_end = nil, options = {}) ⇒ TimeSpan

Returns a new instance of TimeSpan.



527
528
529
530
531
# File 'lib/kamelopard/classes.rb', line 527

def initialize(ts_begin = nil, ts_end = nil, options = {})
    super options
    @begin = ts_begin unless ts_begin.nil?
    @end = ts_end unless ts_end.nil?
end

Instance Attribute Details

#beginObject

Returns the value of attribute begin.



526
527
528
# File 'lib/kamelopard/classes.rb', line 526

def begin
  @begin
end

#endObject

Returns the value of attribute end.



526
527
528
# File 'lib/kamelopard/classes.rb', line 526

def end
  @end
end

Instance Method Details

#to_kml(elem = nil, ns = nil) ⇒ Object



533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# File 'lib/kamelopard/classes.rb', line 533

def to_kml(elem = nil, ns = nil)
    prefix = ''
    prefix = ns + ':' unless ns.nil?

    k = XML::Node.new "#{prefix}TimeSpan"
    super(k)
    if not @begin.nil? then
        w = XML::Node.new 'begin'
        w << @begin
        k << w
    end
    if not @end.nil? then
        w = XML::Node.new 'end'
        w << @end
        k << w
        elem << k unless elem.nil?
    end
    k
end