Sha256: 3767dbdc288377c8f183620754bdb8e12846bd15eac9a9862c2ee206758e3a45

Contents?: true

Size: 625 Bytes

Versions: 6

Compression:

Stored size: 625 Bytes

Contents

module PubliSci
  module Readers
    module Output
      def output(string, options={},append=false)
        options[:type] = [:string] unless options[:type]
        base = options[:file_base]
        name = options[:file_name]
        types = Array(options[:type])

        if types.include? :print
          puts string
        end

        if types.include? :file
          raise "no file specified output" unless name

          method = append ? 'a' : 'w'
          open("#{base}#{name}", method) { |f| f.write str }
        end

        if types.include? :string
          string
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
publisci-0.1.6 lib/publisci/output.rb
publisci-0.1.5 lib/publisci/output.rb
publisci-0.1.4 lib/publisci/output.rb
publisci-0.1.3 lib/publisci/output.rb
publisci-0.1.2 lib/bio-publisci/output.rb
bio-publisci-0.1.0 lib/bio-publisci/output.rb