Class: KML::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/kml/object.rb

Overview

Base class for all KML objects

Direct Known Subclasses

ColorStyle, Feature, LatLonBox, Link, LookAt, StyleSelector

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = nil) ⇒ Object

Initialize the object, optionally passing a Hash of attributes to set.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kml/object.rb', line 8

def initialize(attributes=nil)
  if attributes
    case attributes
    when Hash
      attributes.each do |name, value|
        self.__send__("#{name}=".to_sym, value)
      end
    else
      raise ArgumentError, "Attributes must be specified as a Hash"
    end
  end
end

Instance Attribute Details

#idObject

The KML object ID



5
6
7
# File 'lib/kml/object.rb', line 5

def id
  @id
end

Instance Method Details

#parse(node) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/kml/object.rb', line 21

def parse(node)
  self.id = node['id']
  node.element_children.each do |cld|
    yield cld
  end
  self
end