-
Ruby OptionParser Ruby
In order to parse user inputs passed to CLI Scripts we can use the Ruby class
OptionParser
. With that it’s possible to define an argument specification like required/optional, or restrict values or even convert into a specified class. Find out how to configureOptionParser
and use it.-
Ruby CLI Script Ruby
To create CLI script that runs Ruby code is super fast and straightforward. With that you can run any Ruby code directly from terminal, including your own gem. Let’s take a look what’s need to be done in order to get a nice maintainable CLI script written in Ruby.
-
Ruby Struct and OpenStruct classes Ruby
Ruby
Struct
andOpenStruct
are two different classes that handle to keep some data into a class instance. Although they have similar name and features they are actually very different in usage. Let’s highlight the differences between these two classes and find out the best scenarios for using each one.-
Ruby Case Statement and the `threequals` Ruby
Ruby
case/when/else
statement uses the Ruby operator===
, also known as threequals. There are some nice implementations of===
that we have to know. So let’s see some of them.-
DSL for Rails API calls Ruby Rails
My goal is to encapsulate a API with service classes using a DSL similar to
ActiveRecord
. This way we can use methods likewhere
,find_by
, etc. In order to achieve that I created a class to abstract a json API using the gem faraday and the result is very cool.-
Configuring a Rails Application Ruby Rails
There are a lot to consider when configuring a Rails application, such as variables organization, environments, security credentials, etc. Among so many different ways to do that I’m going to show my preferred way using what Rails has to offer with
config_for
.