Class: MeetingBuddy::Session
- Inherits:
-
Object
- Object
- MeetingBuddy::Session
- Defined in:
- lib/meeting_buddy/session.rb
Overview
Manages session-specific data for MeetingBuddy
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #current_transcript ⇒ Object
-
#initialize(name: nil, handlers: []) ⇒ Session
constructor
A new instance of Session.
- #start ⇒ Object
- #stop ⇒ Object
- #transcript_log ⇒ Object
- #update_transcript(text) ⇒ Object
- #whisper_log ⇒ Object
Constructor Details
#initialize(name: nil, handlers: []) ⇒ Session
Returns a new instance of Session.
10 11 12 13 14 15 16 17 18 |
# File 'lib/meeting_buddy/session.rb', line 10 def initialize(name: nil, handlers: []) @name = name || Time.now.strftime("%Y-%m-%d_%H-%M-%S") @base_path = File.join(MeetingBuddy.cache_dir, "sessions", @name) @handlers = handlers @signal = MeetingSignal.new setup_transcriber FileUtils.mkdir_p base_path FileUtils.touch(transcript_log) end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
8 9 10 |
# File 'lib/meeting_buddy/session.rb', line 8 def base_path @base_path end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
8 9 10 |
# File 'lib/meeting_buddy/session.rb', line 8 def handlers @handlers end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/meeting_buddy/session.rb', line 8 def name @name end |
Instance Method Details
#current_transcript ⇒ Object
46 47 48 |
# File 'lib/meeting_buddy/session.rb', line 46 def current_transcript File.exist?(transcript_log) ? File.read(transcript_log) : "" end |
#start ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/meeting_buddy/session.rb', line 20 def start Sync do |task| listener_task = task.async { start_listener } @tasks = [ {name: "Listener", task: listener_task} ] task.yield until @shutdown end end |
#stop ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/meeting_buddy/session.rb', line 30 def stop @shutdown = true @tasks&.each do |task_info| MeetingBuddy.config.logger.info "Stopping #{task_info[:name]}..." task_info[:task].wait end end |
#transcript_log ⇒ Object
38 39 40 |
# File 'lib/meeting_buddy/session.rb', line 38 def transcript_log File.join(@base_path, "transcript.log") end |
#update_transcript(text) ⇒ Object
50 51 52 53 |
# File 'lib/meeting_buddy/session.rb', line 50 def update_transcript(text) File.open(transcript_log, "a") { |f| f.puts text } @handlers.each { |h| h.on_transcription(text) } end |
#whisper_log ⇒ Object
42 43 44 |
# File 'lib/meeting_buddy/session.rb', line 42 def whisper_log File.join(@base_path, "whisper.log") end |