ruby

How to Write Json in Ruby

less than 1 minute read

Just like when parsing json in ruby you need to require the json library to write hashes and arrays to json strings. Unlike Javascript and PHP you don’t call...

How to Parse Json in Ruby

less than 1 minute read

In Ruby you parse json by first including the json library (either the one provided with the language - or any one of the gems that provide the same function...

How to Write a TCP Echo Server in Ruby

less than 1 minute read

In ruby you have lowlevel access to all the same methods that you do in C. But you also have some higher level sugar on top of that - and a program that does...

How to Write Xml in Ruby

less than 1 minute read

In Ruby there is no built-in support for parsing and writing xml. There are however a couple of gems (packages) that allow you to do exactly this. If you are...

How to Read a file in Ruby

less than 1 minute read

In ruby you read a file in two steps. First open the file, and then iterate over the contents. (In this instance we loop over the contents of a text file so ...

How to Read Program Arguments in Ruby

less than 1 minute read

Ruby has a global ARGV array which contains all arguments. Contrary to e.g. C and PHP it does not, however, contain the script name. This means the hello wor...