Class: Ukiryu::StandardInput

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

Overview

Standard input/output file handles

This class represents special file handles for stdin/stdout/stderr that are recognized by CLI tools.

Examples:

# Reading from stdin
input = Ukiryu::IO::StandardInput.new
input.read

# Writing to stdout
output = Ukiryu::IO::StandardOutput.new
output.write("data")

Constant Summary collapse

FILENO =

The stdin file descriptor

0

Class Method Summary collapse

Class Method Details

.stdin?(path) ⇒ Boolean

Check if a path represents stdin

Examples:

Ukiryu::IO::StandardInput.stdin?("-")  # => true
Ukiryu::IO::StandardInput.stdin?(:stdin)  # => true

Parameters:

  • path (String, Symbol)

    the path to check

Returns:

  • (Boolean)

    true if the path represents stdin



159
160
161
162
# File 'lib/ukiryu/io.rb', line 159

def self.stdin?(path)
  path = path.to_s if path.is_a?(Symbol)
  [$stdin, '-', '/dev/stdin'].include?(path)
end