Class: YandexSpeechApi::Speed
- Inherits:
-
Object
- Object
- YandexSpeechApi::Speed
- Defined in:
- lib/yandex_speech/speed.rb
Defined Under Namespace
Classes: SpeedModeNotAllowed, SpeedValueNotInRange
Instance Attribute Summary collapse
-
#value ⇒ Float
readonly
In range [(0.1)..3.0].
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(speed) ⇒ Speed
constructor
A new instance of Speed.
Constructor Details
#initialize(speed) ⇒ Speed
Returns a new instance of Speed.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yandex_speech/speed.rb', line 31 def initialize(speed) @value = if speed.is_a? Numeric speed.round 2 else Speed.modes[speed.downcase.to_sym] end raise SpeedModeNotAllowed, speed if @value.nil? raise SpeedValueNotInRange, @value unless speed_in_valid_range? @value end |
Instance Attribute Details
#value ⇒ Float (readonly)
Returns In range [(0.1)..3.0].
29 30 31 |
# File 'lib/yandex_speech/speed.rb', line 29 def value @value end |
Class Method Details
.modes ⇒ Hash
15 16 17 18 19 20 21 22 23 |
# File 'lib/yandex_speech/speed.rb', line 15 def modes { :slowest => 0.1, # minimal allowed speed :slow => 0.5, :standard => 1.0, # default :fast => 1.5, :fastest => 3.0 # maximal allowed speed } end |