Class: UniversalPipeHandler::Base

Inherits:
Object
  • Object
show all
Includes:
Colours
Defined in:
lib/universal_pipe_handler/base/base.rb

Overview

UniversalPipeHandler::Base

Direct Known Subclasses

Cmdlet, CmdletsHandler, Shell

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ Base

#

initialize

#


34
35
36
37
38
39
40
41
42
43
# File 'lib/universal_pipe_handler/base/base.rb', line 34

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.[](i = '') ⇒ Object

#

UniversalPipeHandler::Base[]

#


139
140
141
# File 'lib/universal_pipe_handler/base/base.rb', line 139

def self.[](i = '')
  new(i)
end

Instance Method Details

#allowed_actions?Boolean Also known as: registered_actions?

#

allowed_actions?

Return every allowed action. This will not be needed by every subclass, so perhaps this may have to be changed at one point in time.

#

Returns:

  • (Boolean)


84
85
86
# File 'lib/universal_pipe_handler/base/base.rb', line 84

def allowed_actions?
  ::UniversalPipeHandler.all_actions?
end

#chdir(i) ⇒ Object Also known as: cd

#

chdir

#


112
113
114
# File 'lib/universal_pipe_handler/base/base.rb', line 112

def chdir(i)
  FileUtils.chdir(i)
end

#commandline_arguments?Boolean

#

commandline_arguments?

#

Returns:

  • (Boolean)


66
67
68
# File 'lib/universal_pipe_handler/base/base.rb', line 66

def commandline_arguments?
  @commandline_arguments
end

#copy(from, to) ⇒ Object

#

copy

#


91
92
93
# File 'lib/universal_pipe_handler/base/base.rb', line 91

def copy(from, to)
  FileUtils.copy(from, to)
end

#first_argument?Boolean Also known as: first?

#

first_argument?

#

Returns:

  • (Boolean)


73
74
75
# File 'lib/universal_pipe_handler/base/base.rb', line 73

def first_argument?
  @commandline_arguments.first
end

#mkdir(i) ⇒ Object

#

mkdir

#


105
106
107
# File 'lib/universal_pipe_handler/base/base.rb', line 105

def mkdir(i)
  FileUtils.mkdir_p(i)
end

#register_sigintObject

#

register_sigint

#


119
120
121
# File 'lib/universal_pipe_handler/base/base.rb', line 119

def register_sigint
  Signal.trap('SIGINT') { exit }
end

#remove_quotes(i) ⇒ Object

#

remove_quotes

#


98
99
100
# File 'lib/universal_pipe_handler/base/base.rb', line 98

def remove_quotes(i)
  i.delete('"')
end

#resetObject

#

reset (reset tag)

#


48
49
50
51
52
53
# File 'lib/universal_pipe_handler/base/base.rb', line 48

def reset
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
end

#return_pwdObject

#

return_pwd

#


132
133
134
# File 'lib/universal_pipe_handler/base/base.rb', line 132

def return_pwd
  "#{Dir.pwd}/".squeeze('')
end

#runObject

#

run (run tag)

#


126
127
# File 'lib/universal_pipe_handler/base/base.rb', line 126

def run
end

#set_commandline_arguments(i = '') ⇒ Object

#

set_commandline_arguments

#


58
59
60
61
# File 'lib/universal_pipe_handler/base/base.rb', line 58

def set_commandline_arguments(i = '')
  i = [i].flatten.compact
  @commandline_arguments = i
end