Class: Kamelopard::Feature

Inherits:
Object
  • Object
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 Object

#comment, #id

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Feature

Returns a new instance of Feature.



567
568
569
570
571
572
573
# File 'lib/kamelopard/classes.rb', line 567

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

Instance Attribute Details

#abstractViewObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def abstractView
  @abstractView
end

#addressDetailsObject

Returns the value of attribute addressDetails.



565
566
567
# File 'lib/kamelopard/classes.rb', line 565

def addressDetails
  @addressDetails
end

#atom_authorObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def atom_author
  @atom_author
end

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def atom_link
  @atom_link
end

#descriptionObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def description
  @description
end

#extendedDataObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def extendedData
  @extendedData
end

#metadataObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def 
  @metadata
end

#nameObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def name
  @name
end

#openObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def open
  @open
end

#phoneNumberObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def phoneNumber
  @phoneNumber
end

#regionObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def region
  @region
end

#snippetObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def snippet
  @snippet
end

#stylesObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def styles
  @styles
end

#styleSelectorObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def styleSelector
  @styleSelector
end

#styleUrlObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def styleUrl
  @styleUrl
end

#timeprimitiveObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def timeprimitive
  @timeprimitive
end

#visibilityObject

Abatract class



561
562
563
# File 'lib/kamelopard/classes.rb', line 561

def visibility
  @visibility
end

Class Method Details

.add_author(o, a) ⇒ Object



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

def self.add_author(o, a)
    e = REXML::Element.new 'atom:name'
    e.text = a
    f = REXML::Element.new 'atom:author'
    f << e
    o << f
end

Instance Method Details

#styles_to_kml(elem) ⇒ Object



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

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

#timespanObject



579
580
581
# File 'lib/kamelopard/classes.rb', line 579

def timespan
    @timeprimitive
end

#timespan=(t) ⇒ Object



587
588
589
# File 'lib/kamelopard/classes.rb', line 587

def timespan=(t)
    @timeprimitive = t
end

#timestampObject



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

def timestamp
    @timeprimitive
end

#timestamp=(t) ⇒ Object



583
584
585
# File 'lib/kamelopard/classes.rb', line 583

def timestamp=(t)
    @timeprimitive = t
end

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

Yields:

  • (elem)


620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
# File 'lib/kamelopard/classes.rb', line 620

def to_kml(elem = nil)
    elem = REXML::Element.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.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