Class: Feature

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

Overview

Abstract class corresponding to KML’s Feature object.

Direct Known Subclasses

Container, Overlay, Placemark

Instance Attribute Summary collapse

Attributes inherited from KMLObject

#comment, #id

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Feature

Returns a new instance of Feature.



539
540
541
542
543
544
545
# File 'lib/kamelopard/classes.rb', line 539

def initialize (name = nil)
    super()
    @name = name
    @visibility = true
    @open = false
    @styles = []
end

Instance Attribute Details

#abstractViewObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def abstractView
  @abstractView
end

#addressDetailsObject

Returns the value of attribute addressDetails.



537
538
539
# File 'lib/kamelopard/classes.rb', line 537

def addressDetails
  @addressDetails
end

#atom_authorObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def atom_author
  @atom_author
end

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def atom_link
  @atom_link
end

#descriptionObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def description
  @description
end

#extendedDataObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def extendedData
  @extendedData
end

#metadataObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def 
  @metadata
end

#nameObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def name
  @name
end

#openObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def open
  @open
end

#phoneNumberObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def phoneNumber
  @phoneNumber
end

#regionObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def region
  @region
end

#snippetObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def snippet
  @snippet
end

#stylesObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def styles
  @styles
end

#styleSelectorObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def styleSelector
  @styleSelector
end

#styleUrlObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def styleUrl
  @styleUrl
end

#timeprimitiveObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def timeprimitive
  @timeprimitive
end

#visibilityObject

Abstract class



533
534
535
# File 'lib/kamelopard/classes.rb', line 533

def visibility
  @visibility
end

Instance Method Details

#styles_to_kml(indent = 0) ⇒ Object



613
614
615
616
617
618
619
# File 'lib/kamelopard/classes.rb', line 613

def styles_to_kml(indent = 0)
    k = ''
    @styles.each do |a|
        k << a.to_kml(indent)
    end
    k
end

#timespanObject



551
552
553
# File 'lib/kamelopard/classes.rb', line 551

def timespan
    @timeprimitive
end

#timespan=(t) ⇒ Object



559
560
561
# File 'lib/kamelopard/classes.rb', line 559

def timespan=(t)
    @timeprimitive = t
end

#timestampObject



547
548
549
# File 'lib/kamelopard/classes.rb', line 547

def timestamp
    @timeprimitive
end

#timestamp=(t) ⇒ Object



555
556
557
# File 'lib/kamelopard/classes.rb', line 555

def timestamp=(t)
    @timeprimitive = t
end

#to_kml(indent = 0) ⇒ Object



584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
# File 'lib/kamelopard/classes.rb', line 584

def to_kml(indent = 0)
    k = ''
    if self.class == Feature then k << "#{ ' ' * indent }<Feature id=\"#{ @id }\">\n" end
    k << super 
    k << kml_array([
            [@name, 'name', true],
            [(@visibility.nil? || @visibility) ? 1 : 0, 'visibility', true],
            [(! @open.nil? && @open) ? 1 : 0, 'open', true],
            [@atom_author, "<atom:author><atom:name>#{ @atom_author }</atom:name></atom:author>", false],
            [@atom_link, 'atom:link', true],
            [@address, 'address', true],
            [@addressDetails, 'xal:AddressDetails', true],
            [@phoneNumber, 'phoneNumber', true],
            [@description, 'description', true],
            [@styleUrl, 'styleUrl', true],
            [@styleSelector, "<styleSelector>#{@styleSelector.nil? ? '' : @styleSelector.to_kml}</styleSelector>", false ],
            [@metadata, 'Metadata', true ],
            [@extendedData, 'ExtendedData', true ]
        ], (indent))
    k << styles_to_kml(indent)
    k << @snippet.to_kml(indent) unless @snippet.nil?
    k << @abstractView.to_kml(indent) unless @abstractView.nil?
    k << @timeprimitive.to_kml(indent) unless @timeprimitive.nil?
    k << @region.to_kml(indent) unless @region.nil?
    k << yield if block_given?
    if self.class == Feature then k << "#{ ' ' * indent }</Feature>\n" end
    k
end