Overview There are three components that are in the picture when it comes to managing the permissions of a file. User – Abbreviated by ‘u’ Group – Abbreviated by ‘g’ Other– Abbreviated…
Posts
JSON parse a file or string in Ruby Language
Overview json module of ruby can be used a JSON parse a file or string in ruby language https://ruby-doc.org/stdlib-2.6.3/libdoc/json/rdoc/JSON.html It provides a parse function that can be used to parse a file….
Run Ruby language code in command line or terminal – Single-line and Multiline
Overview It is possible to run a ruby code directly on a command line or the terminal itself. We need to pass the -e flag. This is the syntax for the same…
How to handle failure in a command in bash or terminal
Overview In case the failure of the command should not stop the execution of the program, then the below way can be used. If the command fails then the output will be…
Check if a file is writable or not in Ruby language
Overview File class of ruby provides the below method that can be used to check if a file is writable by the effective user and group id of the current process. Here…
Get or Extract Query Params from a URL in Ruby Language
Overview URI module can be used to parse a URL and extract all parts https://ruby-doc.org/stdlib-2.5.1/libdoc/uri/rdoc/URI.html Once the given URL is parsed correctly, then it will return the URI object. We can then…
Get full hostname and port from a URL in Ruby Language
Overview URI module of ruby can be used to get all parts from a URL. This module can be used to parse a URL and extract all parts https://ruby-doc.org/stdlib-2.5.1/libdoc/uri/rdoc/URI.html Once the given…
Convert Query Param String to Query Param Hash in Ruby Language
Overview Assume we have below query param string We want the output as Program Below is the program for the same Output
Extract a URL from a string in Ruby Language
Overview URI module can be used to extract URL from a given string https://ruby-doc.org/stdlib-2.5.1/libdoc/uri/rdoc/URI.html We can use the Extract method of the URI module https://ruby-doc.org/stdlib-2.5.1/libdoc/uri/rdoc/URI.html#method-c-extract Below is the signature of the method…
Parse a URL and extract all the parts in Ruby Language
Overview URI module can be used to parse a URL and extract all parts https://ruby-doc.org/stdlib-2.5.1/libdoc/uri/rdoc/URI.html Once the given URL is parsed correctly, then it will return the URI object. We can then…