Class: Legion::Extensions::Agentic::Self::SelfTalk::Helpers::InnerVoice
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::SelfTalk::Helpers::InnerVoice
- Defined in:
- lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#bias_direction ⇒ Object
readonly
Returns the value of attribute bias_direction.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#voice_type ⇒ Object
readonly
Returns the value of attribute voice_type.
-
#volume ⇒ Object
Returns the value of attribute volume.
Instance Method Summary collapse
- #amplify!(amount = Constants::VOLUME_BOOST) ⇒ Object
- #dampen!(amount = Constants::VOLUME_DECAY) ⇒ Object
- #dominant? ⇒ Boolean
-
#initialize(name:, voice_type:, volume: Constants::DEFAULT_VOLUME, bias_direction: nil, active: true) ⇒ InnerVoice
constructor
A new instance of InnerVoice.
- #mute! ⇒ Object
- #quiet? ⇒ Boolean
- #to_h ⇒ Object
- #unmute! ⇒ Object
- #volume_label ⇒ Object
Constructor Details
#initialize(name:, voice_type:, volume: Constants::DEFAULT_VOLUME, bias_direction: nil, active: true) ⇒ InnerVoice
Returns a new instance of InnerVoice.
15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 15 def initialize(name:, voice_type:, volume: Constants::DEFAULT_VOLUME, bias_direction: nil, active: true) @id = SecureRandom.uuid @name = name @voice_type = voice_type @volume = volume.clamp(0.0, 1.0) @bias_direction = bias_direction @active = active @created_at = Time.now.utc end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
13 14 15 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 13 def active @active end |
#bias_direction ⇒ Object (readonly)
Returns the value of attribute bias_direction.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 12 def bias_direction @bias_direction end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 12 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 12 def name @name end |
#voice_type ⇒ Object (readonly)
Returns the value of attribute voice_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 12 def voice_type @voice_type end |
#volume ⇒ Object
Returns the value of attribute volume.
13 14 15 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 13 def volume @volume end |
Instance Method Details
#amplify!(amount = Constants::VOLUME_BOOST) ⇒ Object
25 26 27 28 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 25 def amplify!(amount = Constants::VOLUME_BOOST) @volume = (@volume + amount).clamp(0.0, 1.0) self end |
#dampen!(amount = Constants::VOLUME_DECAY) ⇒ Object
30 31 32 33 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 30 def dampen!(amount = Constants::VOLUME_DECAY) @volume = (@volume - amount).clamp(0.0, 1.0) self end |
#dominant? ⇒ Boolean
45 46 47 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 45 def dominant? @volume >= 0.7 end |
#mute! ⇒ Object
35 36 37 38 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 35 def mute! @active = false self end |
#quiet? ⇒ Boolean
49 50 51 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 49 def quiet? @volume <= 0.3 end |
#to_h ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 57 def to_h { id: @id, name: @name, voice_type: @voice_type, volume: @volume.round(10), volume_label: volume_label, bias_direction: @bias_direction, active: @active, dominant: dominant?, quiet: quiet?, created_at: @created_at } end |
#unmute! ⇒ Object
40 41 42 43 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 40 def unmute! @active = true self end |
#volume_label ⇒ Object
53 54 55 |
# File 'lib/legion/extensions/agentic/self/self_talk/helpers/inner_voice.rb', line 53 def volume_label Constants.dominance_label(@volume) end |