Class: IconStyle

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

Overview

Corresponds to KML’s IconStyle object.

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(href, scale = 1, heading = 0, hs_x = 0.5, hs_y = 0.5, hs_xunits = :fraction, hs_yunits = :fraction, color = 'ffffffff', colormode = :normal) ⇒ IconStyle

Returns a new instance of IconStyle.



876
877
878
879
880
881
882
# File 'lib/kamelopard/classes.rb', line 876

def initialize(href, scale = 1, heading = 0, hs_x = 0.5, hs_y = 0.5, hs_xunits = :fraction, hs_yunits = :fraction, color = 'ffffffff', colormode = :normal)
    super(color, colormode)
    @scale = scale
    @heading = heading
    @icon = Icon.new(href) unless href.nil?
    @hotspot = KMLxy.new(hs_x, hs_y, hs_xunits, hs_yunits) unless (hs_x.nil? and hs_y.nil? and hs_xunits.nil? and hs_yunits.nil?)
end

Instance Attribute Details

#headingObject

Returns the value of attribute heading.



874
875
876
# File 'lib/kamelopard/classes.rb', line 874

def heading
  @heading
end

#hotspotObject

Returns the value of attribute hotspot.



874
875
876
# File 'lib/kamelopard/classes.rb', line 874

def hotspot
  @hotspot
end

#iconObject

Returns the value of attribute icon.



874
875
876
# File 'lib/kamelopard/classes.rb', line 874

def icon
  @icon
end

#scaleObject

Returns the value of attribute scale.



874
875
876
# File 'lib/kamelopard/classes.rb', line 874

def scale
  @scale
end

Instance Method Details

#to_kml(indent = 0) ⇒ Object



884
885
886
887
888
889
890
891
892
893
894
# File 'lib/kamelopard/classes.rb', line 884

def to_kml(indent = 0)
    k = <<-iconstyle1
#{ ' ' * indent }<IconStyle id="#{@id}">
#{ super(indent + 4) }
   iconstyle1
   k << "#{ ' ' * indent }    <scale>#{@scale}</scale>\n" unless @scale.nil?
   k << "#{ ' ' * indent }    <heading>#{@heading}</heading>\n" unless @heading.nil?
   k << @icon.to_kml(indent + 4) unless @icon.nil?
   k << "#{ ' ' * indent }    <hotSpot x=\"#{@hotspot.x}\" y=\"#{@hotspot.y}\" xunits=\"#{@hotspot.xunits}\" yunits=\"#{@hotspot.yunits}\" />\n" unless @hotspot.nil?
   k << "#{ ' ' * indent }</IconStyle>\n"
end