Class: Mcoin::Command::Base

Inherits:
OptionParser
  • Object
show all
Defined in:
lib/mcoin/command/base.rb

Overview

:nodoc:

Direct Known Subclasses

Common, Ticker

Defined Under Namespace

Classes: Option

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



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

def initialize
  super

  prepare
  self.banner = '=== Mcoin : BTC Monitor Tool ==='
  self.class.options&.each { |option| option.register(self) }
end

Class Attribute Details

.commandsObject (readonly)

Returns the value of attribute commands.



8
9
10
# File 'lib/mcoin/command/base.rb', line 8

def commands
  @commands
end

.optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/mcoin/command/base.rb', line 8

def options
  @options
end

Instance Attribute Details

#optionObject (readonly)

Returns the value of attribute option.



21
22
23
# File 'lib/mcoin/command/base.rb', line 21

def option
  @option
end

Class Method Details

.description(description = nil) ⇒ Object



10
11
12
13
# File 'lib/mcoin/command/base.rb', line 10

def description(description = nil)
  return @description if description.nil?
  @description = description
end

.option(mode, name, *args) ⇒ Object



15
16
17
18
# File 'lib/mcoin/command/base.rb', line 15

def option(mode, name, *args)
  @options ||= []
  @options.push(Option.new(mode, name, *args))
end

Instance Method Details

#executeObject

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/mcoin/command/base.rb', line 40

def execute
  raise NotImplementedError
end

#parse!Object



35
36
37
38
# File 'lib/mcoin/command/base.rb', line 35

def parse!
  super
  self
end

#prepareObject



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

def prepare
  @option = OpenStruct.new
end