Class: Kamelopard::ListStyle

Inherits:
ColorStyle 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.

Instance Attribute Summary collapse

Attributes inherited from ColorStyle

#color, #colorMode

Attributes inherited from Object

#comment, #id

Instance Method Summary collapse

Methods inherited from ColorStyle

#alpha, #alpha=, #blue, #blue=, #green, #green=, #red, #red=, #validate_colorMode

Constructor Details

#initialize(bgcolor = nil, state = nil, href = nil, listitemtype = nil) ⇒ ListStyle

Returns a new instance of ListStyle.



1013
1014
1015
1016
1017
1018
1019
# File 'lib/kamelopard/classes.rb', line 1013

def initialize(bgcolor = nil, state = nil, href = nil, listitemtype = nil)
    super(nil, :normal)
    @bgcolor = bgcolor
    @state = state
    @href = href
    @listitemtype = listitemtype
end

Instance Attribute Details

#bgColorObject

Returns the value of attribute bgColor.



1011
1012
1013
# File 'lib/kamelopard/classes.rb', line 1011

def bgColor
  @bgColor
end

#hrefObject

Returns the value of attribute href.



1011
1012
1013
# File 'lib/kamelopard/classes.rb', line 1011

def href
  @href
end

#listItemTypeObject

Returns the value of attribute listItemType.



1011
1012
1013
# File 'lib/kamelopard/classes.rb', line 1011

def listItemType
  @listItemType
end

#stateObject

Returns the value of attribute state.



1011
1012
1013
# File 'lib/kamelopard/classes.rb', line 1011

def state
  @state
end

Instance Method Details

#to_kml(elem = nil) ⇒ Object



1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
# File 'lib/kamelopard/classes.rb', line 1021

def to_kml(elem = nil)
    k = REXML::Element.new 'ListStyle'
    super k
    Kamelopard.kml_array(k, [
        [@listitemtype, 'listItemType'],
        [@bgcolor, 'bgColor']
    ])
    if (! @state.nil? or ! @href.nil?) then
        i = REXML::Element.new 'ItemIcon'
        Kamelopard.kml_array(i, [
            [ @state, 'state' ],
            [ @href, 'href' ]
        ])
        k.elements << i
    end
    elem.elements << k unless elem.nil?
    k
end