Sha256: 9bc1f7ca540ca2c765a0d15b0cc9b217fa6984a243cd1dc48fb89283b89daa7d
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
module Vedeu class Application # :nocov: # @param options [Hash] # @return [] def self.start(options = {}) new(options).start end # @param options [Hash] # @return [Application] def initialize(options = {}) @options = options end # @return [] def start Terminal.open(mode) do Terminal.set_cursor_mode Vedeu.events.trigger(:_initialize_) runner { main_sequence } end end private attr_reader :options def runner if interactive? interactive { yield } else run_once { yield } end end def main_sequence Input.capture end def interactive? options.fetch(:interactive) end def interactive loop { yield } rescue ModeSwitch if Terminal.raw_mode? Application.start({ mode: :cooked }) else Application.start({ mode: :raw }) end end def run_once yield end def mode options.fetch(:mode) end def debug Vedeu::API::Trace.call if options.fetch(:debug) end def options defaults.merge!(@options) end def defaults { debug: false, interactive: true, mode: :raw } end # :nocov: end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.17 | lib/vedeu/application.rb |
vedeu-0.1.16 | lib/vedeu/application.rb |