Class: Ukiryu::Execution::CommandInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/execution/command_info.rb

Overview

Execution command information

Encapsulates details about the executed command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(executable:, arguments:, full_command:, shell: nil, tool_name: nil, command_name: nil) ⇒ CommandInfo

Returns a new instance of CommandInfo.



11
12
13
14
15
16
17
18
# File 'lib/ukiryu/execution/command_info.rb', line 11

def initialize(executable:, arguments:, full_command:, shell: nil, tool_name: nil, command_name: nil)
  @executable = executable
  @arguments = arguments
  @full_command = full_command
  @shell = shell
  @tool_name = tool_name
  @command_name = command_name
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



9
10
11
# File 'lib/ukiryu/execution/command_info.rb', line 9

def arguments
  @arguments
end

#command_nameObject (readonly)

Returns the value of attribute command_name.



9
10
11
# File 'lib/ukiryu/execution/command_info.rb', line 9

def command_name
  @command_name
end

#executableObject (readonly)

Returns the value of attribute executable.



9
10
11
# File 'lib/ukiryu/execution/command_info.rb', line 9

def executable
  @executable
end

#full_commandObject (readonly)

Returns the value of attribute full_command.



9
10
11
# File 'lib/ukiryu/execution/command_info.rb', line 9

def full_command
  @full_command
end

#shellObject (readonly)

Returns the value of attribute shell.



9
10
11
# File 'lib/ukiryu/execution/command_info.rb', line 9

def shell
  @shell
end

#tool_nameObject (readonly)

Returns the value of attribute tool_name.



9
10
11
# File 'lib/ukiryu/execution/command_info.rb', line 9

def tool_name
  @tool_name
end

Instance Method Details

#argument_countInteger

Get argument count

Returns:

  • (Integer)

    number of arguments



30
31
32
# File 'lib/ukiryu/execution/command_info.rb', line 30

def argument_count
  @arguments.count
end

#executable_nameString

Get the executable name only

Returns:

  • (String)

    executable name



23
24
25
# File 'lib/ukiryu/execution/command_info.rb', line 23

def executable_name
  File.basename(@executable)
end

#inspectString

Inspect

Returns:

  • (String)

    inspection string



44
45
46
# File 'lib/ukiryu/execution/command_info.rb', line 44

def inspect
  "#<Ukiryu::Execution::CommandInfo exe=#{executable_name.inspect} args=#{argument_count}>"
end

#to_hHash

Convert to hash

Returns:

  • (Hash)

    command info as hash



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ukiryu/execution/command_info.rb', line 51

def to_h
  {
    executable: @executable,
    executable_name: executable_name,
    tool_name: @tool_name,
    command_name: @command_name,
    arguments: @arguments,
    full_command: @full_command,
    shell: @shell
  }
end

#to_sString

String representation

Returns:

  • (String)

    command string



37
38
39
# File 'lib/ukiryu/execution/command_info.rb', line 37

def to_s
  @full_command
end