Class: Kamelopard::ListStyle

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

Overview

Corresponds to KML’s ListStyle object. Color is stored as an 8-character hex string, with two characters each of alpha, blue, green, and red values, in that order, matching the ordering the KML spec demands. – This doesn’t descend from ColorStyle because I don’t want the to_kml() call to super() adding color and colorMode elements to the KML – Google Earth complains about ‘em ++

Instance Attribute Summary collapse

Attributes inherited from Object

#comment, #kml_id, #master_only

Instance Method Summary collapse

Methods inherited from Object

#_alternate_to_kml, #change, #master_only?, parse

Constructor Details

#initialize(options = {}) ⇒ ListStyle

Returns a new instance of ListStyle.



1610
1611
1612
1613
1614
1615
# File 'lib/kamelopard/classes.rb', line 1610

def initialize(options = {})
#bgcolor = nil, state = nil, href = nil, listitemtype = nil)
    @state = :open
    @bgColor = 'ffffffff'
    super
end

Instance Attribute Details

#bgColorObject

Returns the value of attribute bgColor.



1608
1609
1610
# File 'lib/kamelopard/classes.rb', line 1608

def bgColor
  @bgColor
end

#hrefObject

Returns the value of attribute href.



1608
1609
1610
# File 'lib/kamelopard/classes.rb', line 1608

def href
  @href
end

#listItemTypeObject

Returns the value of attribute listItemType.



1608
1609
1610
# File 'lib/kamelopard/classes.rb', line 1608

def listItemType
  @listItemType
end

#stateObject

Returns the value of attribute state.



1608
1609
1610
# File 'lib/kamelopard/classes.rb', line 1608

def state
  @state
end

Instance Method Details

#to_kml(elem = nil) ⇒ Object



1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
# File 'lib/kamelopard/classes.rb', line 1617

def to_kml(elem = nil)
    k = XML::Node.new 'ListStyle'

    super k
    Kamelopard.kml_array(k, [
        [@listItemType, 'listItemType'],
        [@bgColor, 'bgColor']
    ])
    if (! @state.nil? or ! @href.nil?) then
        i = XML::Node.new 'ItemIcon'
        Kamelopard.kml_array(i, [
            [ @state, 'state' ],
            [ @href, 'href' ]
        ])
        k << i
    end
    elem << k unless elem.nil?
    k
end