Class: KMLObject
- Inherits:
-
Object
- Object
- KMLObject
- Defined in:
- lib/kamelopard/classes.rb
Overview
Base class for all Kamelopard objects. Manages object ID and a single comment string associated with the object
Direct Known Subclasses
AbstractView, ColorStyle, Feature, Geometry, Link, Region, StyleSelector, TimePrimitive, Tour, TourPrimitive
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(comment = nil) ⇒ KMLObject
constructor
A new instance of KMLObject.
-
#to_kml(indent = 0) ⇒ Object
Returns KML string for this object.
Constructor Details
#initialize(comment = nil) ⇒ KMLObject
Returns a new instance of KMLObject.
87 88 89 90 |
# File 'lib/kamelopard/classes.rb', line 87 def initialize(comment = nil) @id = "#{self.class.name}_#{ get_next_id }" @comment = comment.gsub(/</, '<') unless comment.nil? end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
85 86 87 |
# File 'lib/kamelopard/classes.rb', line 85 def comment @comment end |
#id ⇒ Object
Returns the value of attribute id.
85 86 87 |
# File 'lib/kamelopard/classes.rb', line 85 def id @id end |
Instance Method Details
#to_kml(indent = 0) ⇒ Object
Returns KML string for this object. Objects should override this method
93 94 95 96 97 98 99 |
# File 'lib/kamelopard/classes.rb', line 93 def to_kml(indent = 0) if @comment.nil? or @comment == '' then '' else "#{ ' ' * indent }<!-- #{ @comment } -->\n" end end |