Class: Folder

Inherits:
Container show all
Defined in:
lib/kamelopard/classes.rb

Overview

Corresponds to KML’s Folder object.

Instance Attribute Summary collapse

Attributes inherited from Feature

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

Attributes inherited from KMLObject

#comment, #id

Instance Method Summary collapse

Methods inherited from Container

#<<

Methods inherited from Feature

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

Constructor Details

#initialize(name = nil) ⇒ Folder

Returns a new instance of Folder.



639
640
641
642
643
644
645
# File 'lib/kamelopard/classes.rb', line 639

def initialize(name = nil)
    super()
    @name = name
    @styles = []
    @folders = []
    Document.instance.folders << self
end

Instance Attribute Details

#foldersObject

Returns the value of attribute folders.



637
638
639
# File 'lib/kamelopard/classes.rb', line 637

def folders
  @folders
end

#parent_folderObject

Returns the value of attribute parent_folder.



637
638
639
# File 'lib/kamelopard/classes.rb', line 637

def parent_folder
  @parent_folder
end

#stylesObject

Returns the value of attribute styles.



637
638
639
# File 'lib/kamelopard/classes.rb', line 637

def styles
  @styles
end

Instance Method Details

#has_parent?Boolean

Folders can have parent folders; returns true if this folder has one

Returns:

  • (Boolean)


661
662
663
# File 'lib/kamelopard/classes.rb', line 661

def has_parent?
    not @parent_folder.nil?
end

#to_kml(indent = 0) ⇒ Object



647
648
649
650
651
652
653
654
655
656
657
658
# File 'lib/kamelopard/classes.rb', line 647

def to_kml(indent = 0)
    h = "#{ ' ' * indent }<Folder id=\"#{@id}\">\n"
    h << super(indent + 4)
    @features.each do |a|
        h << a.to_kml(indent + 4)
    end
    @folders.each do |a|
        h << a.to_kml(indent + 4)
    end
    h << "#{ ' ' * indent }</Folder>\n";
    h
end