Class: Kamelopard::Feature

Inherits:
Object
  • Object
show all
Includes:
Snippet
Defined in:
lib/kamelopard/classes.rb

Overview

Abstract class corresponding to KML’s Feature object.

Direct Known Subclasses

Container, NetworkLink, Overlay, Placemark

Instance Attribute Summary collapse

Attributes included from Snippet

#maxLines, #snippet_text

Attributes inherited from Object

#comment, #kml_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Snippet

#snippet_to_kml

Methods inherited from Object

#change

Constructor Details

#initialize(name = nil, options = {}) ⇒ Feature

Returns a new instance of Feature.



578
579
580
581
582
583
584
# File 'lib/kamelopard/classes.rb', line 578

def initialize (name = nil, options = {})
    @visibility = true
    @open = false
    @styles = []
    super options
    @name = name unless name.nil?
end

Instance Attribute Details

#abstractViewObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def abstractView
  @abstractView
end

#addressDetailsObject

Returns the value of attribute addressDetails.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def addressDetails
  @addressDetails
end

#atom_authorObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def atom_author
  @atom_author
end

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def atom_link
  @atom_link
end

#descriptionObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def description
  @description
end

#extendedDataObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def extendedData
  @extendedData
end

#metadataObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def 
  @metadata
end

#nameObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def name
  @name
end

#openObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def open
  @open
end

#phoneNumberObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def phoneNumber
  @phoneNumber
end

#regionObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def region
  @region
end

#snippetObject (readonly)

Returns the value of attribute snippet.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def snippet
  @snippet
end

#stylesObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def styles
  @styles
end

#styleSelectorObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def styleSelector
  @styleSelector
end

#styleUrlObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def styleUrl
  @styleUrl
end

#timeprimitiveObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def timeprimitive
  @timeprimitive
end

#visibilityObject

Abstract class



570
571
572
# File 'lib/kamelopard/classes.rb', line 570

def visibility
  @visibility
end

Class Method Details

.add_author(o, a) ⇒ Object



645
646
647
648
649
650
651
# File 'lib/kamelopard/classes.rb', line 645

def self.add_author(o, a)
    e = XML::Node.new 'atom:name'
    e << a.to_s
    f = XML::Node.new 'atom:author'
    f << e
    o << f
end

Instance Method Details

#hideObject

Hides the object. Note that this governs only whether the object is initially visible or invisible; to show or hide the feature dynamically during a tour, use an AnimatedUpdate object



599
600
601
# File 'lib/kamelopard/classes.rb', line 599

def hide
    @visibility = false
end

#showObject

Shows the object. See note for hide() method



604
605
606
# File 'lib/kamelopard/classes.rb', line 604

def show
    @visibility = true
end

#styles_to_kml(elem) ⇒ Object



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

def styles_to_kml(elem)
    @styles.each do |a|
        a.to_kml(elem)
    end
end

#timespanObject



612
613
614
# File 'lib/kamelopard/classes.rb', line 612

def timespan
    @timeprimitive
end

#timespan=(t) ⇒ Object



620
621
622
# File 'lib/kamelopard/classes.rb', line 620

def timespan=(t)
    @timeprimitive = t
end

#timestampObject



608
609
610
# File 'lib/kamelopard/classes.rb', line 608

def timestamp
    @timeprimitive
end

#timestamp=(t) ⇒ Object



616
617
618
# File 'lib/kamelopard/classes.rb', line 616

def timestamp=(t)
    @timeprimitive = t
end

#to_kml(elem = nil) {|elem| ... } ⇒ Object

Yields:

  • (elem)


653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
# File 'lib/kamelopard/classes.rb', line 653

def to_kml(elem = nil)
    elem = XML::Node.new 'Feature' if elem.nil?
    super elem
    Kamelopard.kml_array(elem, [
            [@name, 'name'],
            [(@visibility.nil? || @visibility) ? 1 : 0, 'visibility'],
            [(! @open.nil? && @open) ? 1 : 0, 'open'],
            [@atom_author, lambda { |o| Feature.add_author(o, @atom_author) }],
            [@atom_link, 'atom:link'],
            [@address, 'address'],
            [@addressDetails, 'xal:AddressDetails'],
            [@phoneNumber, 'phoneNumber'],
            [@description, 'description'],
            [@styleUrl, 'styleUrl'],
            [@styleSelector, lambda { |o| @styleSelector.to_kml(o) }],
            [@metadata, 'Metadata' ],
            [@extendedData, 'ExtendedData' ]
        ])
    styles_to_kml(elem)
    snippet_to_kml(elem) unless @snippet_text.nil?
    @abstractView.to_kml(elem) unless @abstractView.nil?
    @timeprimitive.to_kml(elem) unless @timeprimitive.nil?
    @region.to_kml(elem) unless @region.nil?
    yield(elem) if block_given?
    elem
end