Sha256: 2ffcdee569fa5b673ba0ca554264606cfd6a02ad0275d5eca77e192b67525eef

Contents?: true

Size: 948 Bytes

Versions: 14

Compression:

Stored size: 948 Bytes

Contents

# frozen_string_literal: true

module Appydave
  module Tools
    module GptContext
      # OutputHandler is responsible for writing the output to the desired target
      class OutputHandler
        def initialize(content, options)
          @content = content
          @output_targets = options.output_target
          @working_directory = options.working_directory
        end

        def execute
          @output_targets.each do |target|
            case target
            when 'clipboard'
              Clipboard.copy(@content)
            when /^.+$/
              write_to_file(target)
            end
          end
        end

        private

        attr_reader :content, :output_targets, :working_directory

        def write_to_file(target)
          resolved_path = Pathname.new(target).absolute? ? target : File.join(working_directory, target)
          File.write(resolved_path, content)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
appydave-tools-0.13.0 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.12.0 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.11 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.10 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.9 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.8 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.7 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.6 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.5 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.4 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.3 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.2 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.1 lib/appydave/tools/gpt_context/output_handler.rb
appydave-tools-0.11.0 lib/appydave/tools/gpt_context/output_handler.rb