Class: Document

Inherits:
Container show all
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

Attributes inherited from Feature

#abstractView, #addressDetails, #atom_author, #atom_link, #description, #extendedData, #metadata, #name, #open, #phoneNumber, #region, #snippet, #styleSelector, #styleUrl, #styles, #timeprimitive, #visibility

Attributes inherited from KMLObject

#comment, #id

Instance Method Summary collapse

Methods inherited from Container

#<<

Methods inherited from Feature

#timespan, #timespan=, #timestamp, #timestamp=

Constructor Details

#initializeDocument

Returns a new instance of Document.



684
685
686
687
688
# File 'lib/kamelopard/classes.rb', line 684

def initialize
    @tours = []
    @folders = []
    @styles = []
end

Instance Attribute Details

#flyto_modeObject

Returns the value of attribute flyto_mode.



682
683
684
# File 'lib/kamelopard/classes.rb', line 682

def flyto_mode
  @flyto_mode
end

#foldersObject

Returns the value of attribute folders.



682
683
684
# File 'lib/kamelopard/classes.rb', line 682

def folders
  @folders
end

#toursObject

Returns the value of attribute tours.



682
683
684
# File 'lib/kamelopard/classes.rb', line 682

def tours
  @tours
end

#uses_xalObject

Returns the value of attribute uses_xal.



682
683
684
# File 'lib/kamelopard/classes.rb', line 682

def uses_xal
  @uses_xal
end

Instance Method Details

#folderObject

Returns the current Folder object



697
698
699
700
701
702
# File 'lib/kamelopard/classes.rb', line 697

def folder
    if @folders.size == 0 then
        Folder.new
    end
    @folders.last
end

#styles_to_kml(indent) ⇒ Object



704
705
706
# File 'lib/kamelopard/classes.rb', line 704

def styles_to_kml(indent)
    ''
end

#to_kmlObject



708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
# File 'lib/kamelopard/classes.rb', line 708

def to_kml
    xal = ''
    if @uses_xal then
        xal = ' xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"'
    end
    h = <<-doc_header
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"#{ xal }>
<Document>
    doc_header

    h << super(4)

    # Print styles first
    @styles.map do |a| h << a.to_kml(4) unless a.attached? end

    # then folders
    @folders.map do |a| h << a.to_kml(4) unless a.has_parent? end

    # then tours
    @tours.map do |a| h << a.to_kml(4) end
    h << "</Document>\n</kml>\n"

    h
end

#tourObject

Returns the current Tour object



691
692
693
694
# File 'lib/kamelopard/classes.rb', line 691

def tour
    @tours << Tour.new if @tours.length == 0
    @tours.last
end