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?

Constructor Details

#initialize(options = {}) ⇒ ListStyle

Returns a new instance of ListStyle.



1407
1408
1409
1410
1411
1412
# File 'lib/kamelopard/classes.rb', line 1407

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.



1405
1406
1407
# File 'lib/kamelopard/classes.rb', line 1405

def bgColor
  @bgColor
end

#hrefObject

Returns the value of attribute href.



1405
1406
1407
# File 'lib/kamelopard/classes.rb', line 1405

def href
  @href
end

#listItemTypeObject

Returns the value of attribute listItemType.



1405
1406
1407
# File 'lib/kamelopard/classes.rb', line 1405

def listItemType
  @listItemType
end

#stateObject

Returns the value of attribute state.



1405
1406
1407
# File 'lib/kamelopard/classes.rb', line 1405

def state
  @state
end

Instance Method Details

#to_kml(elem = nil) ⇒ Object



1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
# File 'lib/kamelopard/classes.rb', line 1414

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