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.
1155
1156
1157
1158
|
# File 'lib/kamelopard/classes.rb', line 1155
def initialize(color = nil, options = {})
super options
@color = color unless color.nil?
end
|
Instance Attribute Details
Returns the value of attribute color.
1152
1153
1154
|
# File 'lib/kamelopard/classes.rb', line 1152
def color
@color
end
|
#colorMode ⇒ Object
Returns the value of attribute colorMode.
1153
1154
1155
|
# File 'lib/kamelopard/classes.rb', line 1153
def colorMode
@colorMode
end
|
Instance Method Details
1169
1170
1171
|
# File 'lib/kamelopard/classes.rb', line 1169
def alpha
@color[0,2]
end
|
#alpha=(a) ⇒ Object
1173
1174
1175
|
# File 'lib/kamelopard/classes.rb', line 1173
def alpha=(a)
@color[0,2] = a
end
|
1177
1178
1179
|
# File 'lib/kamelopard/classes.rb', line 1177
def blue
@color[2,2]
end
|
1181
1182
1183
|
# File 'lib/kamelopard/classes.rb', line 1181
def blue=(a)
@color[2,2] = a
end
|
1185
1186
1187
|
# File 'lib/kamelopard/classes.rb', line 1185
def green
@color[4,2]
end
|
#green=(a) ⇒ Object
1189
1190
1191
|
# File 'lib/kamelopard/classes.rb', line 1189
def green=(a)
@color[4,2] = a
end
|
1193
1194
1195
|
# File 'lib/kamelopard/classes.rb', line 1193
def red
@color[6,2]
end
|
1197
1198
1199
|
# File 'lib/kamelopard/classes.rb', line 1197
def red=(a)
@color[6,2] = a
end
|
#to_kml(elem = nil) ⇒ Object
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
|
# File 'lib/kamelopard/classes.rb', line 1201
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
1160
1161
1162
|
# File 'lib/kamelopard/classes.rb', line 1160
def validate_colorMode(a)
raise "colorMode must be either \"normal\" or \"random\"" unless a == :normal or a == :random
end
|