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.



1449
1450
1451
1452
1453
1454
# File 'lib/kamelopard/classes.rb', line 1449

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.



1447
1448
1449
# File 'lib/kamelopard/classes.rb', line 1447

def bgColor
  @bgColor
end

#hrefObject

Returns the value of attribute href.



1447
1448
1449
# File 'lib/kamelopard/classes.rb', line 1447

def href
  @href
end

#listItemTypeObject

Returns the value of attribute listItemType.



1447
1448
1449
# File 'lib/kamelopard/classes.rb', line 1447

def listItemType
  @listItemType
end

#stateObject

Returns the value of attribute state.



1447
1448
1449
# File 'lib/kamelopard/classes.rb', line 1447

def state
  @state
end

Instance Method Details

#to_kml(elem = nil) ⇒ Object



1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
# File 'lib/kamelopard/classes.rb', line 1456

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