Class: YandexSpeechApi::Key
- Inherits:
-
Object
- Object
- YandexSpeechApi::Key
- Defined in:
- lib/yandex_speech/key.rb
Defined Under Namespace
Classes: InvalidGlobalKey, KeyNotDefined
Class Method Summary collapse
-
.global_key=(new_key) ⇒ Object
Sets global key.
-
.global_key? ⇒ TrueClass, FalseClass
True if global key set, otherwise returns false.
Instance Method Summary collapse
-
#get ⇒ Key
Returns an key.
-
#initialize(key) ⇒ Key
constructor
class << self.
-
#present? ⇒ TrueClass, FalseClass
Key present?.
Constructor Details
#initialize(key) ⇒ Key
class << self
39 40 41 |
# File 'lib/yandex_speech/key.rb', line 39 def initialize(key) @instance_key = key end |
Class Method Details
.global_key=(new_key) ⇒ Object
Sets global key.
15 16 17 18 19 |
# File 'lib/yandex_speech/key.rb', line 15 def global_key=(new_key) key_tmp = new_key.is_a?(Key) ? new_key : Key.new(new_key) raise InvalidGlobalKey, key_tmp unless key_tmp.present? @global_key = key_tmp end |
.global_key? ⇒ TrueClass, FalseClass
Returns True if global key set, otherwise returns false.
25 26 27 |
# File 'lib/yandex_speech/key.rb', line 25 def global_key? !!global_key end |
Instance Method Details
#get ⇒ Key
Returns an key.
51 52 53 54 55 56 57 58 59 |
# File 'lib/yandex_speech/key.rb', line 51 def get if present? return instance_key elsif default? return default.get else raise KeyNotDefined end end |
#present? ⇒ TrueClass, FalseClass
Key present?
67 68 69 |
# File 'lib/yandex_speech/key.rb', line 67 def present? !(instance_key == :unknown) end |