Class: Cohere::Transcribe::TranscriptionRun
- Inherits:
-
Data
- Object
- Data
- Cohere::Transcribe::TranscriptionRun
- Includes:
- Enumerable, Enumerable[TranscriptionResult]
- Defined in:
- lib/cohere/transcribe/types.rb,
sig/cohere/transcribe.rbs
Overview
Immutable, sequence-like result of one API call.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#requested_options ⇒ Object
readonly
Returns the value of attribute requested_options.
-
#resolved_options ⇒ Object
readonly
Returns the value of attribute resolved_options.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
Instance Method Summary collapse
- #[] ⇒ Object
- #each {|arg0| ... } ⇒ Object
- #failed ⇒ Array[TranscriptionResult]
-
#initialize(results:, requested_options:, resolved_options:, statistics:, errors: []) ⇒ TranscriptionRun
constructor
A new instance of TranscriptionRun.
- #length ⇒ Integer (also: #size)
- #ok? ⇒ Boolean (also: #ok)
- #single ⇒ TranscriptionResult
- #skipped ⇒ Array[TranscriptionResult]
- #successful ⇒ Array[TranscriptionResult]
-
#to_h ⇒ Object
Enumerable#to_h otherwise shadows Data#to_h and interprets results as key-value pairs instead of returning this value object's fields.
Constructor Details
#initialize(results:, requested_options:, resolved_options:, statistics:, errors: []) ⇒ TranscriptionRun
Returns a new instance of TranscriptionRun.
469 470 471 472 473 474 475 476 477 |
# File 'lib/cohere/transcribe/types.rb', line 469 def initialize(results:, requested_options:, resolved_options:, statistics:, errors: []) super( results: TypesSupport.tuple(results, field: "results"), requested_options: , resolved_options: , statistics: statistics, errors: TypesSupport.tuple(errors, field: "errors") ) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors
460 461 462 |
# File 'lib/cohere/transcribe/types.rb', line 460 def errors @errors end |
#requested_options ⇒ Object (readonly)
Returns the value of attribute requested_options
460 461 462 |
# File 'lib/cohere/transcribe/types.rb', line 460 def @requested_options end |
#resolved_options ⇒ Object (readonly)
Returns the value of attribute resolved_options
460 461 462 |
# File 'lib/cohere/transcribe/types.rb', line 460 def @resolved_options end |
#results ⇒ Object (readonly)
Returns the value of attribute results
460 461 462 |
# File 'lib/cohere/transcribe/types.rb', line 460 def results @results end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics
460 461 462 |
# File 'lib/cohere/transcribe/types.rb', line 460 def statistics @statistics end |
Instance Method Details
#[](arg0) ⇒ TranscriptionResult #[](arg0) ⇒ Array[TranscriptionResult] #[](arg0, arg1) ⇒ Array[TranscriptionResult]
502 503 504 505 |
# File 'lib/cohere/transcribe/types.rb', line 502 def [](*) selected = results[*] selected.is_a?(Array) ? selected.freeze : selected end |
#each ⇒ self #each ⇒ Enumerator[TranscriptionResult, self]
479 480 481 482 483 |
# File 'lib/cohere/transcribe/types.rb', line 479 def each(&block) return results.each unless block results.each(&block) end |
#failed ⇒ Array[TranscriptionResult]
520 521 522 |
# File 'lib/cohere/transcribe/types.rb', line 520 def failed results.select { |result| result.status == "failed" }.freeze end |
#length ⇒ Integer Also known as: size
497 498 499 |
# File 'lib/cohere/transcribe/types.rb', line 497 def length results.length end |
#ok? ⇒ Boolean Also known as: ok
528 529 530 |
# File 'lib/cohere/transcribe/types.rb', line 528 def ok? failed.empty? && errors.empty? end |
#single ⇒ TranscriptionResult
507 508 509 510 511 512 513 514 |
# File 'lib/cohere/transcribe/types.rb', line 507 def single unless results.length == 1 raise ArgumentError, "Expected exactly one expanded audio file, found #{results.length}" end results.first end |
#skipped ⇒ Array[TranscriptionResult]
524 525 526 |
# File 'lib/cohere/transcribe/types.rb', line 524 def skipped results.select { |result| result.status == "skipped" }.freeze end |
#successful ⇒ Array[TranscriptionResult]
516 517 518 |
# File 'lib/cohere/transcribe/types.rb', line 516 def successful results.select { |result| result.status == "completed" }.freeze end |
#to_h ⇒ Object
Enumerable#to_h otherwise shadows Data#to_h and interprets results as key-value pairs instead of returning this value object's fields.
487 488 489 490 491 492 493 494 495 |
# File 'lib/cohere/transcribe/types.rb', line 487 def to_h { results: results, requested_options: , resolved_options: , statistics: statistics, errors: errors } end |