Class: Kamelopard::SchemaData

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

Overview

Corresponds to KML’s ExtendedData SchemaData objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schemaUrl, simpleData = {}) ⇒ SchemaData

Returns a new instance of SchemaData.



856
857
858
859
860
# File 'lib/kamelopard/classes.rb', line 856

def initialize(schemaUrl, simpleData = {})
    @schemaUrl = schemaUrl
    raise "SchemaData's simpleData attribute should behave like a hash" unless simpleData.respond_to? :keys
    @simpleData = simpleData
end

Instance Attribute Details

#schemaUrlObject

Returns the value of attribute schemaUrl.



855
856
857
# File 'lib/kamelopard/classes.rb', line 855

def schemaUrl
  @schemaUrl
end

#simpleDataObject

Returns the value of attribute simpleData.



855
856
857
# File 'lib/kamelopard/classes.rb', line 855

def simpleData
  @simpleData
end

Instance Method Details

#<<(a) ⇒ Object



862
863
864
# File 'lib/kamelopard/classes.rb', line 862

def <<(a)
    @simpleData.merge a
end

#to_kml(elem = nil) ⇒ Object



866
867
868
869
870
871
872
873
874
875
876
# File 'lib/kamelopard/classes.rb', line 866

def to_kml(elem = nil)
    s = XML::Node.new 'SchemaData'
    s.attributes['schemaUrl'] = @schemaUrl
    @simpleData.each do |k, v|
        sd = XML::Node.new 'SimpleData', v
        sd.attributes['name'] = k
        s << sd
    end
    elem << v unless elem.nil?
    v
end