Class: Kube::Cluster::Ctl

Inherits:
Object
  • Object
show all
Defined in:
lib/kube/cluster/ctl.rb

Constant Summary collapse

GEM_ROOT =
File.expand_path("../../..", __dir__)
COMMAND_TREE =
JSON.parse(
  File.read(File.join(GEM_ROOT, "data", "kubectl-command-tree-v1-minimal.json"))
)
ROOT =
TreeNode.new(
  name:     "kubectl",
  type:     :command,
  children: TreeNode.build(COMMAND_TREE)
)

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



20
21
22
# File 'lib/kube/cluster/ctl.rb', line 20

def method_missing(name, *args, &block)
  CommandNode.new(current_node: ROOT).public_send(name, *args, &block)
end

Instance Method Details

#inspectObject



28
29
30
# File 'lib/kube/cluster/ctl.rb', line 28

def inspect
  "#<#{self.class.name}>"
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/kube/cluster/ctl.rb', line 24

def respond_to_missing?(name, include_private = false)
  CommandNode.new(current_node: ROOT).respond_to?(name) || super
end