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, #master_only

Instance Method Summary collapse

Methods inherited from Object

#_alternate_to_kml, #change, #master_only?

Constructor Details

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

Returns a new instance of TimeSpan.



649
650
651
652
653
# File 'lib/kamelopard/classes.rb', line 649

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

XXX Evidence suggests this doesn’t support unbounded intervals. Fix that, if it’s true.



648
649
650
# File 'lib/kamelopard/classes.rb', line 648

def begin
  @begin
end

#endObject

XXX Evidence suggests this doesn’t support unbounded intervals. Fix that, if it’s true.



648
649
650
# File 'lib/kamelopard/classes.rb', line 648

def end
  @end
end

Instance Method Details

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



655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
# File 'lib/kamelopard/classes.rb', line 655

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
    end
    elem << k unless elem.nil?
    k
end