Module: Mcoin::Command

Defined in:
lib/mcoin/command.rb,
lib/mcoin/command/base.rb,
lib/mcoin/command/common.rb,
lib/mcoin/command/ticker.rb,
lib/mcoin/command/ext/has_type.rb,
lib/mcoin/command/ext/saveable.rb,
lib/mcoin/command/ext/has_market.rb

Overview

The command line interface

Defined Under Namespace

Modules: HasMarket, HasType, Saveable Classes: Base, Common, Ticker

Class Method Summary collapse

Class Method Details

.commandsObject



29
30
31
32
33
# File 'lib/mcoin/command.rb', line 29

def commands
  constants.select do |klass|
    const_get(klass).is_a?(Class)
  end - %i[Base Common]
end

.executeObject



19
20
21
# File 'lib/mcoin/command.rb', line 19

def execute
  pick.new.parse!.execute
end

.pickObject



23
24
25
26
27
# File 'lib/mcoin/command.rb', line 23

def pick
  command = ARGV.first&.capitalize
  return Common unless commands.include?(command&.to_sym)
  const_get(command)
end