Module: Hornetseye::RGB_::Match
- Included in:
- Node
- Defined in:
- lib/multiarray/rgb.rb
Overview
Namespace containing method for matching elements of type RGB_
Instance Method Summary collapse
-
#align(context) ⇒ Object
Perform type alignment.
-
#fit(*values) ⇒ Class
Method for matching elements of type RGB_.
Instance Method Details
#align(context) ⇒ Object
Perform type alignment
Align this type to another. This is used to prefer single-precision floating point in certain cases.
507 508 509 510 511 512 513 |
# File 'lib/multiarray/rgb.rb', line 507 def align(context) if self < RGB_ Hornetseye::RGB element_type.align(context) else super context end end |
#fit(*values) ⇒ Class
Method for matching elements of type RGB_
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/multiarray/rgb.rb', line 474 def fit( *values ) if values.all? { |value| value.is_a? RGB or value.is_a? Float or value.is_a? Integer } if values.any? { |value| value.is_a? RGB } elements = values.inject([]) do |arr,value| if value.is_a? RGB arr + [ value.r, value.g, value.b ] else arr + [ value ] end end element_fit = fit *elements if element_fit == OBJECT super *values else Hornetseye::RGB element_fit end else super *values end else super *values end end |