class Treyja::Exe
Public Class Methods
new(args)
click to toggle source
# File lib/treyja/exe.rb, line 28 def initialize args @args = args end
Public Instance Methods
options()
click to toggle source
# File lib/treyja/exe.rb, line 32 def options @options ||= {} end
patch_round(round)
click to toggle source
# File lib/treyja/exe.rb, line 36 def patch_round round if round > 0 ::Float.instance_variable_set "@round_digits", round end end
run()
click to toggle source
# File lib/treyja/exe.rb, line 42 def run opts = OptionParser.new opts.on("--output DIR") opts.on("--normalize") opts.on("--round INT") opts.on("--version") do puts "Version: #{Treyja::VERSION}" return end opts.on("-h", "--help") do Treyja::Command::Help.new.run return end command, file = opts.parse!(@args, into: options) patch_round options.fetch(:round, 4).to_f case command when "dump" reader = Treyja::Reader.new file Treyja::Command::Dump.new(reader).run when "json" reader = Treyja::Reader.new file Treyja::Command::Json.new(reader).run when "image" output_dir = options[:output] raise "--output option required" unless output_dir reader = Treyja::Reader.new file Treyja::Command::Image.new(reader, output_dir, options.slice(:normalize)).run when "csv" reader = Treyja::Reader.new file Treyja::Command::Csv.new(reader).run when nil Treyja::Command::Help.new.run else puts "Unknown command: #{command}" Treyja::Command::Help.new.run end end