Class: Kamelopard::StyleMap
- Inherits:
-
StyleSelector
- Object
- Object
- StyleSelector
- Kamelopard::StyleMap
- Defined in:
- lib/kamelopard/classes.rb
Overview
Corresponds to KML’s StyleMap object.
Instance Attribute Summary
Attributes inherited from Object
Instance Method Summary collapse
-
#initialize(pairs = {}, options = {}) ⇒ StyleMap
constructor
StyleMap manages pairs.
-
#merge(a) ⇒ Object
Adds a new Style to the StyleMap.
- #to_kml(elem = nil) ⇒ Object
Methods inherited from StyleSelector
Methods inherited from Object
Constructor Details
#initialize(pairs = {}, options = {}) ⇒ StyleMap
StyleMap manages pairs. The first entry in each pair is a string key, the second is either a Style or a styleUrl. It will be assumed to be the latter if its kind_of? method doesn’t claim it’s a Style object
1191 1192 1193 1194 |
# File 'lib/kamelopard/classes.rb', line 1191 def initialize(pairs = {}, = {}) super @pairs = pairs end |
Instance Method Details
#merge(a) ⇒ Object
Adds a new Style to the StyleMap.
1197 1198 1199 |
# File 'lib/kamelopard/classes.rb', line 1197 def merge(a) @pairs.merge!(a) end |
#to_kml(elem = nil) ⇒ Object
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 |
# File 'lib/kamelopard/classes.rb', line 1201 def to_kml(elem = nil) t = XML::Node.new 'StyleMap' super t @pairs.each do |k, v| p = XML::Node.new 'Pair' key = XML::Node.new 'key' key << k.to_s p. << key if v.kind_of? Style then v.to_kml(p) else s = XML::Node.new 'styleUrl' s << v.to_s p << s end t << p end elem << t unless elem.nil? t end |