Class: Kamelopard::Document
- Includes:
- Singleton
- Defined in:
- lib/kamelopard/classes.rb
Overview
Represents KML’s Document class. This is a Singleton object; Kamelopard scripts can (for now) manage only one Document at a time.
Instance Attribute Summary collapse
-
#doc_folders ⇒ Object
Returns the value of attribute doc_folders.
-
#doc_styles ⇒ Object
Returns the value of attribute doc_styles.
-
#doc_tours ⇒ Object
Returns the value of attribute doc_tours.
-
#flyto_mode ⇒ Object
Returns the value of attribute flyto_mode.
-
#uses_xal ⇒ Object
Returns the value of attribute uses_xal.
Attributes inherited from Feature
#abstractView, #addressDetails, #atom_author, #atom_link, #description, #extendedData, #metadata, #name, #open, #phoneNumber, #region, #snippet, #styleSelector, #styleUrl, #styles, #timeprimitive, #visibility
Attributes included from Snippet
Attributes inherited from Object
Instance Method Summary collapse
-
#folder ⇒ Object
Returns the current Folder object.
- #get_kml_document ⇒ Object
-
#initialize(options = {}) ⇒ Document
constructor
A new instance of Document.
- #to_kml ⇒ Object
-
#tour ⇒ Object
Returns the current Tour object.
Methods inherited from Container
Methods inherited from Feature
add_author, #hide, #show, #styles_to_kml, #timespan, #timespan=, #timestamp, #timestamp=
Methods included from Snippet
Methods inherited from Object
Constructor Details
#initialize(options = {}) ⇒ Document
Returns a new instance of Document.
772 773 774 775 776 777 |
# File 'lib/kamelopard/classes.rb', line 772 def initialize( = {}) @doc_tours = [] @doc_folders = [] @doc_styles = [] super end |
Instance Attribute Details
#doc_folders ⇒ Object
Returns the value of attribute doc_folders.
770 771 772 |
# File 'lib/kamelopard/classes.rb', line 770 def doc_folders @doc_folders end |
#doc_styles ⇒ Object
Returns the value of attribute doc_styles.
770 771 772 |
# File 'lib/kamelopard/classes.rb', line 770 def doc_styles @doc_styles end |
#doc_tours ⇒ Object
Returns the value of attribute doc_tours.
770 771 772 |
# File 'lib/kamelopard/classes.rb', line 770 def doc_tours @doc_tours end |
#flyto_mode ⇒ Object
Returns the value of attribute flyto_mode.
770 771 772 |
# File 'lib/kamelopard/classes.rb', line 770 def flyto_mode @flyto_mode end |
#uses_xal ⇒ Object
Returns the value of attribute uses_xal.
770 771 772 |
# File 'lib/kamelopard/classes.rb', line 770 def uses_xal @uses_xal end |
Instance Method Details
#folder ⇒ Object
Returns the current Folder object
786 787 788 789 790 791 |
# File 'lib/kamelopard/classes.rb', line 786 def folder if @doc_folders.size == 0 then Folder.new end @doc_folders.last end |
#get_kml_document ⇒ Object
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
# File 'lib/kamelopard/classes.rb', line 793 def get_kml_document k = XML::Document.new # XXX fix this #k << XML::XMLDecl.default k.root = XML::Node.new('kml') r = k.root if @uses_xal then r.attributes['xmlns:xal'] = "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" end # XXX Should this be add_namespace instead? r.attributes['xmlns'] = 'http://www.opengis.net/kml/2.2' r.attributes['xmlns:gx'] = 'http://www.google.com/kml/ext/2.2' r.attributes['xmlns:kml'] = 'http://www.opengis.net/kml/2.2' r.attributes['xmlns:atom'] = 'http://www.w3.org/2005/Atom' r << self.to_kml k end |
#to_kml ⇒ Object
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 |
# File 'lib/kamelopard/classes.rb', line 811 def to_kml d = XML::Node.new 'Document' super d # Print styles first @doc_styles.map do |a| d << a.to_kml unless a.attached? end # then folders @doc_folders.map do |a| a.to_kml(d) unless a.has_parent? end # then tours @doc_tours.map do |a| a.to_kml(d) end d end |