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?, parse

Constructor Details

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

Returns a new instance of TimeSpan.



792
793
794
795
796
# File 'lib/kamelopard/classes.rb', line 792

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.



791
792
793
# File 'lib/kamelopard/classes.rb', line 791

def begin
  @begin
end

#endObject

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



791
792
793
# File 'lib/kamelopard/classes.rb', line 791

def end
  @end
end

Instance Method Details

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



798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
# File 'lib/kamelopard/classes.rb', line 798

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