Class: JavaColor
Instance Attribute Summary collapse
-
#java_object ⇒ Object
Returns the value of attribute java_object.
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(options = {}) ⇒ JavaColor
constructor
A new instance of JavaColor.
- #method_missing(m, *args) ⇒ Object
Methods inherited from BaseColor
#adjust, #blue, #blue=, #brightness, #green, #green=, #hue, #object, #red, #red=, #rgb, #rgb=, #saturation
Constructor Details
#initialize(options = {}) ⇒ JavaColor
Returns a new instance of JavaColor.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/libisi/color/java.rb', line 29 def initialize( = {}) # create javacolor out of color-tools = Color.create("colortools",) if .class == String or .class == Symbol raise "Cannot create color out of #{}" unless .respond_to?(:rgb) rgb = .rgb @java_object = JavaBridge.import("java.awt.Color").new(*rgb) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
23 24 25 |
# File 'lib/libisi/color/java.rb', line 23 def method_missing(m, *args) @obj.send(m, *args) end |
Instance Attribute Details
#java_object ⇒ Object
Returns the value of attribute java_object.
27 28 29 |
# File 'lib/libisi/color/java.rb', line 27 def java_object @java_object end |
Instance Method Details
#html ⇒ Object
40 41 42 |
# File 'lib/libisi/color/java.rb', line 40 def html "#" + [@java_object.getRed.to_s(16),@java_object.getGreen.to_s(16),@java_object.getBlue.to_s(16)].map {|v| v.ljust(2,"0")}.join end |