Class: FlatKit::Command

Inherits:
Object
  • Object
show all
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

Direct Known Subclasses

Cat, Merge, Sort

Defined Under Namespace

Classes: Cat, Merge, Sort

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DescendantTracker

children, find_child, inherited

Constructor Details

#initialize(argv:, logger: ::FlatKit.logger, env: ENV) ⇒ Command

Returns a new instance of Command.



34
35
36
37
38
39
# File 'lib/flat_kit/command.rb', line 34

def initialize(argv:, logger: ::FlatKit.logger, env: ENV)
  @argv = argv
  @env = env
  @logger = logger
  parse
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



5
6
7
# File 'lib/flat_kit/command.rb', line 5

def argv
  @argv
end

#envObject (readonly)

Returns the value of attribute env.



6
7
8
# File 'lib/flat_kit/command.rb', line 6

def env
  @env
end

#loggerObject (readonly)

Returns the value of attribute logger.



7
8
9
# File 'lib/flat_kit/command.rb', line 7

def logger
  @logger
end

#optsObject (readonly)

Returns the value of attribute opts.



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

def opts
  @opts
end

#readersObject (readonly)

Returns the value of attribute readers.



9
10
11
# File 'lib/flat_kit/command.rb', line 9

def readers
  @readers
end

#writerObject (readonly)

Returns the value of attribute writer.



10
11
12
# File 'lib/flat_kit/command.rb', line 10

def writer
  @writer
end

Class Method Details

.descriptionObject

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/flat_kit/command.rb', line 16

def self.description
  raise NotImplementedError, "#{self.class} must implement #{self.class}.description"
end

.for(name) ⇒ Object



28
29
30
31
32
# File 'lib/flat_kit/command.rb', line 28

def self.for(name)
  children.find do |child_klass|
    child_klass.name == name
  end
end

.nameObject

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/flat_kit/command.rb', line 12

def self.name
  raise NotImplementedError, "#{self.class} must implement #{self.class}.name"
end

.namesObject



24
25
26
# File 'lib/flat_kit/command.rb', line 24

def self.names
  children.map { |c| c.name }
end

.parserObject

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/flat_kit/command.rb', line 20

def self.parser
  raise NotImplementedError, "#{self.class} must implement #{self.class}.parser"
end

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/flat_kit/command.rb', line 45

def call
  raise NotImplementedError, "#{self.class} must implement #{self.class}.description"
end

#parseObject

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/flat_kit/command.rb', line 41

def parse
  raise NotImplementedError, "#{self.class} must implement #{self.class}#parse"
end