Class: 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 KMLObject

#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.



951
952
953
954
955
956
957
# File 'lib/kamelopard/classes.rb', line 951

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.



949
950
951
# File 'lib/kamelopard/classes.rb', line 949

def bgcolor
  @bgcolor
end

#hrefObject

Returns the value of attribute href.



949
950
951
# File 'lib/kamelopard/classes.rb', line 949

def href
  @href
end

#listitemtypeObject

Returns the value of attribute listitemtype.



949
950
951
# File 'lib/kamelopard/classes.rb', line 949

def listitemtype
  @listitemtype
end

#stateObject

Returns the value of attribute state.



949
950
951
# File 'lib/kamelopard/classes.rb', line 949

def state
  @state
end

Instance Method Details

#to_kml(indent = 0) ⇒ Object



959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
# File 'lib/kamelopard/classes.rb', line 959

def to_kml(indent = 0)
    k = "#{ ' ' * indent }<ListStyle id=\"#{@id}\">\n"
    k << kml_array([
        [@listitemtype, 'listItemType', true],
        [@bgcolor, 'bgColor', true]
    ], indent + 4)
    if (! @state.nil? or ! @href.nil?) then
        k << "#{ ' ' * indent }    <ItemIcon>\n"
        k << "#{ ' ' * indent }        <state>#{@state}</state>\n" unless @state.nil? 
        k << "#{ ' ' * indent }        <href>#{@href}</href>\n" unless @href.nil? 
        k << "#{ ' ' * indent }    </ItemIcon>\n"
    end
    k << "#{ ' ' * indent }</ListStyle>\n"
    k
end