Class: Kamelopard::ColorStyle
- Inherits:
-
Object
- Object
- Object
- Kamelopard::ColorStyle
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.
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?
Constructor Details
#initialize(color = nil, options = {}) ⇒ ColorStyle
Returns a new instance of ColorStyle.
1192
1193
1194
1195
|
# File 'lib/kamelopard/classes.rb', line 1192
def initialize(color = nil, options = {})
super options
@color = color unless color.nil?
end
|
Instance Attribute Details
Returns the value of attribute color.
1189
1190
1191
|
# File 'lib/kamelopard/classes.rb', line 1189
def color
@color
end
|
#colorMode ⇒ Object
Returns the value of attribute colorMode.
1190
1191
1192
|
# File 'lib/kamelopard/classes.rb', line 1190
def colorMode
@colorMode
end
|
Instance Method Details
1206
1207
1208
|
# File 'lib/kamelopard/classes.rb', line 1206
def alpha
@color[0,2]
end
|
#alpha=(a) ⇒ Object
1210
1211
1212
|
# File 'lib/kamelopard/classes.rb', line 1210
def alpha=(a)
@color[0,2] = a
end
|
1214
1215
1216
|
# File 'lib/kamelopard/classes.rb', line 1214
def blue
@color[2,2]
end
|
1218
1219
1220
|
# File 'lib/kamelopard/classes.rb', line 1218
def blue=(a)
@color[2,2] = a
end
|
1222
1223
1224
|
# File 'lib/kamelopard/classes.rb', line 1222
def green
@color[4,2]
end
|
#green=(a) ⇒ Object
1226
1227
1228
|
# File 'lib/kamelopard/classes.rb', line 1226
def green=(a)
@color[4,2] = a
end
|
1230
1231
1232
|
# File 'lib/kamelopard/classes.rb', line 1230
def red
@color[6,2]
end
|
1234
1235
1236
|
# File 'lib/kamelopard/classes.rb', line 1234
def red=(a)
@color[6,2] = a
end
|
#to_kml(elem = nil) ⇒ Object
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
|
# File 'lib/kamelopard/classes.rb', line 1238
def to_kml(elem = nil)
k = elem.nil? ? XML::Node.new('ColorStyle') : elem
super k
e = XML::Node.new 'color'
e << @color
k << e
e = XML::Node.new 'colorMode'
e << @colorMode
k << e
k
end
|
#validate_colorMode(a) ⇒ Object
1197
1198
1199
|
# File 'lib/kamelopard/classes.rb', line 1197
def validate_colorMode(a)
raise "colorMode must be either \"normal\" or \"random\"" unless a == :normal or a == :random
end
|