Sha256: b41e2882af37a311d869e3cba387df0cb9b67a215944488e4c2f5b0f213555a5
Contents?: true
Size: 741 Bytes
Versions: 3
Compression:
Stored size: 741 Bytes
Contents
# frozen_string_literal: true # coding: utf-8 # # Base class of logic class # class BaseLogic def initialize @in = $stdin @out = $stdout @err = $stderr end def source_output(source = $stdout) @out = source end def source_input(source = $stdin) @in = source if source.nil? || source =~ /^-$/ # If the file name is "-", use STDIN. @in = $stdin else file(source) end end def source_err(source = $stderr) @err = source end private def file(filename) @in = File.open(filename) rescue SystemCallError => e @err.puts e.message.to_s # TODO: Define error codes as enum. exit(2) rescue IOError => e @err.puts e.message.to_s exit(2) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cureutils-1.1.0 | lib/cureutils/logic/base_logic.rb |
cureutils-1.0.1 | lib/cureutils/logic/base_logic.rb |
cureutils-1.0.0 | lib/cureutils/logic/base_logic.rb |