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
#comment, #kml_id, #master_only
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
#_alternate_to_kml, #change, #master_only?, parse
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
1712 1713 1714 1715 |
# File 'lib/kamelopard/classes.rb', line 1712 def initialize(pairs = {}, = {}) super @pairs = pairs end |
Instance Method Details
#merge(a) ⇒ Object
Adds a new Style to the StyleMap.
1718 1719 1720 |
# File 'lib/kamelopard/classes.rb', line 1718 def merge(a) @pairs.merge!(a) end |
#to_kml(elem = nil) ⇒ Object
1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 |
# File 'lib/kamelopard/classes.rb', line 1722 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 |