Module: Utils::IRB::String
- Included in:
- String
- Defined in:
- lib/utils/irb.rb
Instance Method Summary collapse
-
#>>(filename) ⇒ Integer
The >> method writes the string content to a file securely.
-
#|(cmd) ⇒ String
The | method executes a shell command and returns its output.
Instance Method Details
#>>(filename) ⇒ Integer
The >> method writes the string content to a file securely.
This method takes a filename and uses File.secure_write to write the string’s content to that file, ensuring secure file handling practices are followed.
721 722 723 |
# File 'lib/utils/irb.rb', line 721 def >>(filename) File.secure_write(filename, self) end |
#|(cmd) ⇒ String
The | method executes a shell command and returns its output.
This method takes a command string, pipes the current string to it via stdin, captures the command’s stdout, and returns the resulting output as a string.
704 705 706 707 708 709 710 |
# File 'lib/utils/irb.rb', line 704 def |(cmd) IO.popen(cmd, 'w+') do |f| f.write self f.close_write return f.read end end |