Class: FlatKit::Command
- Inherits:
-
Object
- Object
- FlatKit::Command
- Extended by:
- DescendantTracker
- Defined in:
- lib/flat_kit/command.rb,
lib/flat_kit/command/cat.rb,
lib/flat_kit/command/sort.rb,
lib/flat_kit/command/merge.rb,
lib/flat_kit/command/stats.rb
Overview
Internal: The base class for all commands in the CLI
Defined Under Namespace
Classes: Cat, Merge, Sort, Stats
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#readers ⇒ Object
readonly
Returns the value of attribute readers.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv:, logger: ::FlatKit.logger, env: ENV) ⇒ Command
constructor
A new instance of Command.
- #parse ⇒ Object
Methods included from DescendantTracker
children, find_child, find_children, inherited
Constructor Details
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
9 10 11 |
# File 'lib/flat_kit/command.rb', line 9 def argv @argv end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
9 10 11 |
# File 'lib/flat_kit/command.rb', line 9 def env @env end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/flat_kit/command.rb', line 9 def logger @logger end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
9 10 11 |
# File 'lib/flat_kit/command.rb', line 9 def opts @opts end |
#readers ⇒ Object (readonly)
Returns the value of attribute readers.
9 10 11 |
# File 'lib/flat_kit/command.rb', line 9 def readers @readers end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
9 10 11 |
# File 'lib/flat_kit/command.rb', line 9 def writer @writer end |
Class Method Details
.description ⇒ Object
15 16 17 |
# File 'lib/flat_kit/command.rb', line 15 def self.description raise NotImplementedError, "#{self.class} must implement #{self.class}.description" end |
.for(name) ⇒ Object
27 28 29 30 31 |
# File 'lib/flat_kit/command.rb', line 27 def self.for(name) children.find do |child_klass| child_klass.name == name end end |
.name ⇒ Object
11 12 13 |
# File 'lib/flat_kit/command.rb', line 11 def self.name raise NotImplementedError, "#{self.class} must implement #{self.class}.name" end |
.names ⇒ Object
23 24 25 |
# File 'lib/flat_kit/command.rb', line 23 def self.names children.map(&:name) end |
.parser ⇒ Object
19 20 21 |
# File 'lib/flat_kit/command.rb', line 19 def self.parser raise NotImplementedError, "#{self.class} must implement #{self.class}.parser" end |
Instance Method Details
#call ⇒ Object
44 45 46 |
# File 'lib/flat_kit/command.rb', line 44 def call raise NotImplementedError, "#{self.class} must implement #{self.class}.description" end |
#parse ⇒ Object
40 41 42 |
# File 'lib/flat_kit/command.rb', line 40 def parse raise NotImplementedError, "#{self.class} must implement #{self.class}#parse" end |