Sha256: 2f159690f57d01558869f06457d3e3ba9681e2ba80e2ad25cf8ec0ac29f34d0d

Contents?: true

Size: 624 Bytes

Versions: 2

Compression:

Stored size: 624 Bytes

Contents

module PubliSci
  module Reader
    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

2 entries across 2 versions & 1 rubygems

Version Path
bio-publisci-0.0.8 lib/bio-publisci/output.rb
bio-publisci-0.0.7 lib/bio-publisci/output.rb