Class: TradeOptions
- Inherits:
-
Object
- Object
- TradeOptions
- Defined in:
- lib/trades/options.rb
Constant Summary collapse
- MARKETS =
Define markets, market aliases and currencies
%w[mtgoxUSD thUSD mtgoxEUR virwoxSLL mtgoxGBP intrsngGBP virtexCAD btceUSD cbxUSD btcexUSD btcdeEUR wbxAUD mtgoxRUB bitmarketEUR mtgoxPLN thEUR mtgoxCAD intrsngUSD mtgoxAUD intrsngEUR btcnCNY thAUD bitstampUSD mtgoxHKD intsngPLN bitmarketUSD bitnzNZD thLRUSD thINR rockSSL mtgoxSGD b2cUSD aqoinEUR mtgoxSEK ruxumUSD thCLP mrcdBRL mtgoxCNY mtgoxCHF mtgoxDKK bitfloorUSD ruxumJPY bitmarketAUD mtgoxJPY ruxumZAR bitmarketPLN ruxumSEK ruxumRUB rockEUR mtgoxNZD rockUSD ruxumCHF bbmBRL globalPLN globalGBP bitmarketRUB ruxumHUF mtgoxTHB ruxumAUD ruxumEUR globalEUR bitmarketGBP ruxumGBP ruxumPLN ruxumSGD ruxumTHB ruxumUAH globalUSD]
- ALIASES =
{"mtgox" => "mtgoxUSD", "th" => "thUSD", "tradehill" => "thUSD"}
- CURRENCIES =
{ "usd" => "USD", "dollar" => "USD", "us" => "USD", "eur" => "EUR", "euro" => "EUR", "euros" => "EUR", "gbp" => "GBP", "pound" => "GBP", "ssl" => "SSL", "secondlife" => "SSL", "cny" => "CNY", "cad" => "CAD", "canadian" => "CAD", "aud" => "AUD", "australian" => "AUD", "aus" => "AUD", "rub" => "RUB", "russian" => "RUB", "rubble" => "RUB", "pln" => "PLN", "polish" => "PLN", "hkd" => "HKD", "hongkong" => "HKD", "nzd" => "NZD", "newzealand" => "NZD", "nz" => "NZD", "sgd" => "SGD", "sek" => "SEK", "clp" => "CLP", "brl" => "BRL", "chf" => "CHF", "dkk" => "DKK", "jpy" => "JPY", "yen" => "JPY", "japan" => "JPY", "zar" => "ZAR", "huf" => "HUF", "thb" => "THB", "uah" => "UAH" }
Class Method Summary collapse
Class Method Details
.parse(args) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/trades/options.rb', line 41 def self.parse(args) # Default options = OpenStruct.new .filter = :markets .markets = [] .currencies = [] .color = true opts = OptionParser.new do |opts| opts. = "Usage: trades [options]\n\n" opts.separator "Options:" # Filter on market opts.on("-m", "--market MARKET", MARKETS, ALIASES, "Filter on MARKET") do |m| .markets << m # << because of multiple currencies end # Filter on currency opts.on("-c", "--currency CURRENCY", CURRENCIES.values.uniq, CURRENCIES, "Filter on CURRENCY") do |c| .filter = :currencies # default is :markets .currencies << c # << because of multiple currencies end # Logging opts.on("-l", "--log [FILENAME]", "Log the results to FILENAME") do |file| file = "/var/log/trades.log" if file.nil? .log = true .logger = Logger.new File.new(file, 'a+') .logger.formatter = proc { |s, d, p, m| "#{m}\n" } end # No-color opts.on_tail("--no-color", "Plain text instead of output colorized") do .color = false end # List of markets opts.on_tail("--markets", "Show a list of all markets") do puts "Markets: #{MARKETS.join ', '}\n\nAliases:" ALIASES.each { |x,y| puts "#{x} for #{y}" } exit end # List of currencies opts.on_tail("--currencies", "Show a list of all currencies") do puts "Currencies: #{CURRENCIES.values.uniq.join ', '}" exit end # Help opts.on_tail("-h", "--help", "Show this message") do puts "#{opts}\n\nMore info: https://github.com/britishtea/Trades" exit end end opts.parse!(args) end |