diff options
author | Joe Rayhawk <jrayhawk@fairlystable.org> | 2023-08-17 18:40:22 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk@fairlystable.org> | 2023-08-17 18:44:51 -0700 |
commit | f7b6daf551ff4bcd03980dfa593b6f8a8e3075d0 (patch) | |
tree | c327efdf79c1b34ade852ae39986ae850f2f4412 /src/obswebsocket.cr | |
parent | 89aff6f0cfccc97df4ad6580d5888b160c190f76 (diff) | |
download | crystal-obs-websocket-f7b6daf551ff4bcd03980dfa593b6f8a8e3075d0.tar.gz crystal-obs-websocket-f7b6daf551ff4bcd03980dfa593b6f8a8e3075d0.zip |
Add pretty_print methods
Diffstat (limited to 'src/obswebsocket.cr')
-rw-r--r-- | src/obswebsocket.cr | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr index b824153..d3432f4 100644 --- a/src/obswebsocket.cr +++ b/src/obswebsocket.cr @@ -972,6 +972,21 @@ module OBS def deletecache( input : String ) @inputs.delete( input ) end + def pretty_print(pp) : Nil + executed = exec_recursive(:pretty_print) do + pp.list("{", self.to_h, "}") do |key, value| + pp.group do + key.pretty_print(pp) + pp.text " =>" + pp.nest do + pp.breakable + value.pretty_print(pp) + end + end + end + end + pp.text "{...}" unless executed + end end class Input @@ -996,6 +1011,12 @@ module OBS value.sourcenamecache( name ) end end + def pretty_print(pp) : Nil + self.name.pretty_print(pp) + self.kind.pretty_print(pp) + self.settings.pretty_print(pp) + self.filters.pretty_print(pp) + end end class InputSettings @@ -1030,6 +1051,11 @@ module OBS def namecache( name : String) @name = name end + def pretty_print(pp) : Nil + @inputkind.pretty_print(pp) + @name.pretty_print(pp) + @inputsettings.pretty_print(pp) + end end class SourceFilters # Note: a property of both OBS::Input and OBS::Scene @@ -1071,6 +1097,10 @@ module OBS @filters_by_name = Hash( String, OBS::SourceFilter ).new @filters_by_index = Array( String ).new end + def pretty_print(pp) : Nil + @sourcename.pretty_print(pp) + self.to_h.pretty_print(pp) + end end class SourceFilter |