mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2026-04-18 13:33:31 +00:00
examples refactored
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
require "obsws"
|
||||
require "perfect_toml"
|
||||
require "yaml"
|
||||
|
||||
OBSWS::LOGGER.info!
|
||||
|
||||
class Observer
|
||||
class Main
|
||||
attr_reader :running
|
||||
|
||||
def initialize(**kwargs)
|
||||
@@ -15,6 +15,10 @@ class Observer
|
||||
@running = true
|
||||
end
|
||||
|
||||
def run
|
||||
sleep(0.1) while running
|
||||
end
|
||||
|
||||
def info
|
||||
resp = @r_client.get_version
|
||||
[
|
||||
@@ -45,14 +49,8 @@ class Observer
|
||||
end
|
||||
end
|
||||
|
||||
def conn_from_toml
|
||||
PerfectTOML.load_file("obs.toml", symbolize_names: true)[:connection]
|
||||
def conn_from_yaml
|
||||
YAML.load_file("obs.yml", symbolize_names: true)[:connection]
|
||||
end
|
||||
|
||||
def main
|
||||
o = Observer.new(**conn_from_toml)
|
||||
|
||||
sleep(0.1) while o.running
|
||||
end
|
||||
|
||||
main if $0 == __FILE__
|
||||
Main.new(**conn_from_yaml).run if $0 == __FILE__
|
||||
|
||||
Reference in New Issue
Block a user