Sha256: 10b4b948d14e7e35815bc3f1517ce74fd78b7dea1bf7b223f334cde449317e3b
Contents?: true
Size: 938 Bytes
Versions: 2
Compression:
Stored size: 938 Bytes
Contents
#! /usr/bin/env ruby # coding: utf-8 # # USAGE: calc [options] str0 str1 files ... require "pp" require "optparse" require "stringio" #require "rubygems" #require "tempfile" require "tefil" ## option analysis options = {} op = OptionParser.new op.banner = [ "Usage: #{File.basename("#{__FILE__}")} [options] [files]", ].join("\n") op.on("-o" , "--overwrite" , "Overwrite."){ options[:overwrite] = true} op.on("-p" , "--preserve" , "Preserve equation with '='."){ options[:preserve] = true} op.on("-r" , "--ruby" , "Use Ruby 'eval' in spite of 'bc -l', powerful but security weakness."){ options[:ruby] = true} #Math::PI や実数乗ができる。 op.parse!(ARGV) options[:overwrite] ||= false tf = Tefil::Calculator.new(options) if ARGV.empty? tf.filter(ARGV) else ## for command line argument io = StringIO.new ARGV.each do |str| io.puts str end io.rewind tf.process_stream(io, $stdout) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tefil-0.1.5 | bin/calc |
tefil-0.1.4 | bin/calc |