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.



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

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.



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

def color
  @color
end

#colorModeObject

Returns the value of attribute colorMode.



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

def colorMode
  @colorMode
end

Instance Method Details

#alphaObject



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

def alpha
    @color[0,2]
end

#alpha=(a) ⇒ Object



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

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

#blueObject



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

def blue
    @color[2,2]
end

#blue=(a) ⇒ Object



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

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

#greenObject



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

def green
    @color[4,2]
end

#green=(a) ⇒ Object



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

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

#redObject



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

def red
    @color[6,2]
end

#red=(a) ⇒ Object



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

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

#to_kml(elem = nil) ⇒ Object



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

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



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

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