Class: Kamelopard::SchemaData
- Inherits:
-
Object
- Object
- Kamelopard::SchemaData
- Defined in:
- lib/kamelopard/classes.rb
Overview
Corresponds to KML’s ExtendedData SchemaData objects
Instance Attribute Summary collapse
-
#schemaUrl ⇒ Object
Returns the value of attribute schemaUrl.
-
#simpleData ⇒ Object
Returns the value of attribute simpleData.
Instance Method Summary collapse
- #<<(a) ⇒ Object
-
#initialize(schemaUrl, simpleData = {}) ⇒ SchemaData
constructor
A new instance of SchemaData.
- #to_kml(elem = nil) ⇒ Object
Constructor Details
#initialize(schemaUrl, simpleData = {}) ⇒ SchemaData
Returns a new instance of SchemaData.
814 815 816 817 818 |
# File 'lib/kamelopard/classes.rb', line 814 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
#schemaUrl ⇒ Object
Returns the value of attribute schemaUrl.
813 814 815 |
# File 'lib/kamelopard/classes.rb', line 813 def schemaUrl @schemaUrl end |
#simpleData ⇒ Object
Returns the value of attribute simpleData.
813 814 815 |
# File 'lib/kamelopard/classes.rb', line 813 def simpleData @simpleData end |
Instance Method Details
#<<(a) ⇒ Object
820 821 822 |
# File 'lib/kamelopard/classes.rb', line 820 def <<(a) @simpleData.merge a end |
#to_kml(elem = nil) ⇒ Object
824 825 826 827 828 829 830 831 832 833 834 |
# File 'lib/kamelopard/classes.rb', line 824 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 |