This mapping has 1 multi-map group: several pairings are equally correct there. The code view shows one arbitrary valid pairing, not the only one.

Before

1# frozen_string_literal: true
2
3require 'process_executer/destination_base'
4
5module ProcessExecuter
6 module Destinations
7 # Handles numeric file descriptors
8 #
9 # @api private
10 class FileDescriptor < ProcessExecuter::DestinationBase
11 # Writes data to the file descriptor
12 #
13 # @param data [String] the data to write
14 # @return [Integer] the number of bytes written
15 # @raise [SystemCallError] if the file descriptor is invalid
16 #
17 # @example
18 # fd_handler = ProcessExecuter::Destinations::FileDescriptor.new(3)
19 # fd_handler.write("Hello world")
20 def write(data)
21 super
22 io = ::IO.open(destination, mode: 'a', autoclose: false)
23 io.write(data)
24 io.close
25 end
26
27 # Determines if this class can handle the given destination
28 #
29 # @param destination [Object] the destination to check
30 # @return [Boolean] true if destination is an Integer that's not stdout/stderr
31 def self.handles?(destination)
32 destination.is_a?(Integer) && ![:out, 1, :err, 2].include?(destination)
33 end
34 end
35 end
36end
37

After

1# frozen_string_literal: true
2
3require_relative 'destination_base'
4
5module ProcessExecuter
6 module Destinations
7 # Handles numeric file descriptors
8 #
9 # @api private
10 class FileDescriptor < DestinationBase
11 # Writes data to the file descriptor
12 #
13 # @param data [String] the data to write
14 #
15 # @return [Integer] the number of bytes written
16 #
17 # @raise [SystemCallError] if the file descriptor is invalid
18 #
19 # @example
20 # fd_handler = ProcessExecuter::Destinations::FileDescriptor.new(3)
21 # fd_handler.write("Hello world")
22 #
23 def write(data)
24 super
25 io = ::IO.open(destination, mode: 'a', autoclose: false)
26 io.write(data).tap { io.close }
27 end
28
29 # Determines if this class can handle the given destination
30 #
31 # @param destination [Object] the destination to check
32 #
33 # @return [Boolean] true if destination is a file descriptor that's not stdout or stderr
34 #
35 def self.handles?(destination)
36 destination.is_a?(Integer) && ![1, 2].include?(destination)
37 end
38 end
39 end
40end
41

Before

program
comment "# frozen_string_literal: true"
call
identifier "require"
argument_list
string
" "'"
string_content "process_executer/destination_base"
" "'"
module
module "module"
constant "ProcessExecuter"
body_statement
module
module "module"
constant "Destinations"
comment "# Handles numeric file descriptors"
comment "#"
comment "# @api private"
body_statement
class
class "class"
constant "FileDescriptor"
superclass
< "<"
scope_resolution
constant "ProcessExecuter"
:: "::"
constant "DestinationBase"
comment "# Writes data to the file descriptor"
comment "#"
comment "# @param data [String] the data to write"
comment "# @return [Integer] the number of bytes written"
comment "# @raise [SystemCallError] if the file descriptor is invalid"
comment "#"
comment "# @example"
comment "# fd_handler = ProcessExecuter::Destinations::FileDescript"...
comment "# fd_handler.write(\"Hello world\")"
body_statement
method
def "def"
identifier "write"
method_parameters
( "("
identifier "data"
) ")"
body_statement
super "super"
assignment (+26 nodes collapsed)
call any 2:3
identifier "io"
. "."
identifier "write"
argument_list
( "("
identifier "data"
) ")"
call any 2:3
identifier "io"
. "."
identifier "close"
end "end"
comment "# Determines if this class can handle the given destination"
comment "#"
comment "# @param destination [Object] the destination to check"
comment "# @return [Boolean] true if destination is an Integer that's"...
singleton_method
def "def"
self "self"
. "."
identifier "handles?"
method_parameters
( "("
identifier "destination"
) ")"
body_statement
binary
call
identifier "destination"
. "."
identifier "is_a?"
argument_list
( "("
constant "Integer"
) ")"
&& "&&"
unary
! "!"
call
array
[ "["
simple_symbol ":out"
, ","
integer "1"
, ","
simple_symbol ":err"
, ","
integer "2"
] "]"
. "."
identifier "include?"
argument_list
( "("
identifier "destination"
) ")"
end "end"
end "end"
end "end"
end "end"

After

program
comment "# frozen_string_literal: true"
call
identifier "require_relative"
argument_list
string
" "'"
string_content "destination_base"
" "'"
module
module "module"
constant "ProcessExecuter"
body_statement
module
module "module"
constant "Destinations"
comment "# Handles numeric file descriptors"
comment "#"
comment "# @api private"
body_statement
class
class "class"
constant "FileDescriptor"
superclass
< "<"
constant "DestinationBase"
comment "# Writes data to the file descriptor"
comment "#"
comment "# @param data [String] the data to write"
comment "#"
comment "# @return [Integer] the number of bytes written"
comment "#"
comment "# @raise [SystemCallError] if the file descriptor is invalid"
comment "#"
comment "# @example"
comment "# fd_handler = ProcessExecuter::Destinations::FileDescript"...
comment "# fd_handler.write(\"Hello world\")"
comment "#"
body_statement
method
def "def"
identifier "write"
method_parameters
( "("
identifier "data"
) ")"
body_statement
super "super"
assignment (+26 nodes collapsed)
call any 2:3
call any 2:3
identifier "io"
. "."
identifier "write"
argument_list
( "("
identifier "data"
) ")"
. "."
identifier "tap"
block
{ "{"
block_body
call any 2:3
identifier "io"
. "."
identifier "close"
} "}"
end "end"
comment "# Determines if this class can handle the given destination"
comment "#"
comment "# @param destination [Object] the destination to check"
comment "#"
comment "# @return [Boolean] true if destination is a file descriptor"...
comment "#"
singleton_method
def "def"
self "self"
. "."
identifier "handles?"
method_parameters
( "("
identifier "destination"
) ")"
body_statement
binary
call
identifier "destination"
. "."
identifier "is_a?"
argument_list
( "("
constant "Integer"
) ")"
&& "&&"
unary
! "!"
call
array
[ "["
integer "1"
, ","
integer "2"
] "]"
. "."
identifier "include?"
argument_list
( "("
identifier "destination"
) ")"
end "end"
end "end"
end "end"
end "end"