lib/rays/painter.rb in rays-0.1.8 vs lib/rays/painter.rb in rays-0.1.9
- old
+ new
@@ -97,22 +97,22 @@
end_paint
end
private
- NONES = [:no, :none]
+ NONES = [:no, :none, nil]
def send_set (setter, getter, no, args, mode = nil)
args = args[0] if args[0].kind_of? Array
raise ArgumentError if args.empty?
arg0 = args[0]
- if args.size == 1 && (!arg0 || NONES.include?(arg0))
+ if args.size == 1 && NONES.include?(arg0)
no ? send(no) : send(setter, nil)
else
case mode
- when :color then args = to_color(args)
+ when :color then args = Color.color *args
end
send setter, *args
end
send getter
end
@@ -131,29 +131,9 @@
if block
Xot::BlockUtil.instance_eval_or_block_call self, &block
send setter, org
end
org
- end
-
- COLORS = {
- black: [0, 0, 0],
- red: [1, 0, 0],
- green: [0, 1, 0],
- blue: [0, 0, 1],
- yellow: [1, 1, 0],
- cyan: [0, 1, 1],
- magenta: [1, 0, 1],
- white: [1, 1, 1],
- gray: [0.5, 0.5, 0.5],
- }.inject({}) {|hash, (name, array)| hash[name] = Color.new *array; hash}
-
- def to_color (args)
- case arg0 = args[0]
- when Symbol then [COLORS[arg0]]
- when String then [(arg0 =~ /^\s*#[\da-fA-F]+\s*$/) ? Color.new(arg0) : COLORS[arg0.intern]]
- else args
- end
end
end# Painter