Class: Kamelopard::ColorStyle

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

Overview

Corresponds to KML’s ColorStyle 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.

Direct Known Subclasses

IconStyle, LabelStyle, LineStyle, PolyStyle

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(color = nil, options = {}) ⇒ ColorStyle

Returns a new instance of ColorStyle.



1353
1354
1355
1356
1357
# File 'lib/kamelopard/classes.rb', line 1353

def initialize(color = nil, options = {})
    super options
    @set_colorMode = false
    @color = color unless color.nil?
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



1350
1351
1352
# File 'lib/kamelopard/classes.rb', line 1350

def color
  @color
end

#colorModeObject

Returns the value of attribute colorMode.



1351
1352
1353
# File 'lib/kamelopard/classes.rb', line 1351

def colorMode
  @colorMode
end

Instance Method Details

#alphaObject



1369
1370
1371
# File 'lib/kamelopard/classes.rb', line 1369

def alpha
    @color[0,2]
end

#alpha=(a) ⇒ Object



1373
1374
1375
# File 'lib/kamelopard/classes.rb', line 1373

def alpha=(a)
    @color[0,2] = a
end

#blueObject



1377
1378
1379
# File 'lib/kamelopard/classes.rb', line 1377

def blue
    @color[2,2]
end

#blue=(a) ⇒ Object



1381
1382
1383
# File 'lib/kamelopard/classes.rb', line 1381

def blue=(a)
    @color[2,2] = a
end

#greenObject



1385
1386
1387
# File 'lib/kamelopard/classes.rb', line 1385

def green
    @color[4,2]
end

#green=(a) ⇒ Object



1389
1390
1391
# File 'lib/kamelopard/classes.rb', line 1389

def green=(a)
    @color[4,2] = a
end

#redObject



1393
1394
1395
# File 'lib/kamelopard/classes.rb', line 1393

def red
    @color[6,2]
end

#red=(a) ⇒ Object



1397
1398
1399
# File 'lib/kamelopard/classes.rb', line 1397

def red=(a)
    @color[6,2] = a
end

#to_kml(elem = nil) ⇒ Object



1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
# File 'lib/kamelopard/classes.rb', line 1401

def to_kml(elem = nil)
    k = elem.nil? ? XML::Node.new('ColorStyle') : elem
    super k
    e = XML::Node.new 'color'
    e << @color
    k << e
    if @set_colorMode then
        e = XML::Node.new 'colorMode'
        e << @colorMode
        k << e
    end
    k
end

#validate_colorMode(a) ⇒ Object



1359
1360
1361
# File 'lib/kamelopard/classes.rb', line 1359

def validate_colorMode(a)
    raise "colorMode must be either \"normal\" or \"random\"" unless a == :normal or a == :random
end