Module: Hornetseye::Sequence_::Match
- Included in:
- Node
- Defined in:
- lib/multiarray/sequence.rb
Overview
Namespace containing method for matching elements of type Sequence_
Instance Method Summary collapse
-
#align(context) ⇒ Object
Perform type alignment.
-
#fit(*values) ⇒ Class
Method for matching elements of type Sequence_.
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.
365 366 367 368 369 370 371 |
# File 'lib/multiarray/sequence.rb', line 365 def align( context ) if self < Sequence_ Hornetseye::Sequence element_type.align( context ), num_elements else super context end end |
#fit(*values) ⇒ Class
Method for matching elements of type Sequence_
343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/multiarray/sequence.rb', line 343 def fit( *values ) n = values.inject 0 do |size,value| value.is_a?( Array ) ? [ size, value.size ].max : size end if n > 0 elements = values.inject [] do |flat,value| flat + ( value.is_a?( Array ) ? value : [ value ] ) end Hornetseye::Sequence fit( *elements ), n else super *values end end |