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.
455 456 457 458 459 460 461 462 463 |
# File 'lib/cohere/transcribe/types.rb', line 455 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
446 447 448 |
# File 'lib/cohere/transcribe/types.rb', line 446 def errors @errors end |
#requested_options ⇒ Object (readonly)
Returns the value of attribute requested_options
446 447 448 |
# File 'lib/cohere/transcribe/types.rb', line 446 def @requested_options end |
#resolved_options ⇒ Object (readonly)
Returns the value of attribute resolved_options
446 447 448 |
# File 'lib/cohere/transcribe/types.rb', line 446 def @resolved_options end |
#results ⇒ Object (readonly)
Returns the value of attribute results
446 447 448 |
# File 'lib/cohere/transcribe/types.rb', line 446 def results @results end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics
446 447 448 |
# File 'lib/cohere/transcribe/types.rb', line 446 def statistics @statistics end |
Instance Method Details
#[](arg0) ⇒ TranscriptionResult #[](arg0) ⇒ Array[TranscriptionResult] #[](arg0, arg1) ⇒ Array[TranscriptionResult]
488 489 490 491 |
# File 'lib/cohere/transcribe/types.rb', line 488 def [](*) selected = results[*] selected.is_a?(Array) ? selected.freeze : selected end |
#each ⇒ self #each ⇒ Enumerator[TranscriptionResult, self]
465 466 467 468 469 |
# File 'lib/cohere/transcribe/types.rb', line 465 def each(&block) return results.each unless block results.each(&block) end |
#failed ⇒ Array[TranscriptionResult]
506 507 508 |
# File 'lib/cohere/transcribe/types.rb', line 506 def failed results.select { |result| result.status == "failed" }.freeze end |
#length ⇒ Integer Also known as: size
483 484 485 |
# File 'lib/cohere/transcribe/types.rb', line 483 def length results.length end |
#ok? ⇒ Boolean Also known as: ok
514 515 516 |
# File 'lib/cohere/transcribe/types.rb', line 514 def ok? failed.empty? && errors.empty? end |
#single ⇒ TranscriptionResult
493 494 495 496 497 498 499 500 |
# File 'lib/cohere/transcribe/types.rb', line 493 def single unless results.length == 1 raise ArgumentError, "Expected exactly one expanded audio file, found #{results.length}" end results.first end |
#skipped ⇒ Array[TranscriptionResult]
510 511 512 |
# File 'lib/cohere/transcribe/types.rb', line 510 def skipped results.select { |result| result.status == "skipped" }.freeze end |
#successful ⇒ Array[TranscriptionResult]
502 503 504 |
# File 'lib/cohere/transcribe/types.rb', line 502 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.
473 474 475 476 477 478 479 480 481 |
# File 'lib/cohere/transcribe/types.rb', line 473 def to_h { results: results, requested_options: , resolved_options: , statistics: statistics, errors: errors } end |