Bundler

If I were to explain bundler to pythonista (like myself) I would say Bundler in Ruby land is like poetry in python land, except it does not create sandbox environment To explain it a little more. It tracks dependencies in a Gemfile (and Gemfile.lock) which then goes in your repo. Other engineers sharing your code would then run bundle install, and they get exact same Gems (including versions) on their machines.

Continue Reading »

Where Are My (Ruby) Gems ?

As I mentioned earlier, I’m trying Lunar nvim starter kit. Latest version of nvim comes with LSP support, and while learning a new language LSP could be really helpful (I think) I had heard of solargraph. Running :LspInstall in nvim gave me option of sorbet as well. But I decided to stick with solargraph. nvim was successful in installing solargraph, or so it told me. But it did not work. LspInfo told me that it did not find solargraph Just to be sure I gem install solargraph from the terminal, before I tried to install LSP from nvim again

Continue Reading »

Exploring `irb`

Start clean I created an alias irb=irb --sample-book-mode This removes the complex prompt like irb(main):001:0> and gives plain and simple >> instead. Get Help! When programming in Python, even today I use dir in Python REPL. So I was looking for the equivalent in Ruby land. Turns out I was comparing apples and oranges (so to speak) As of early 2022, irb has awesome help built-in. It has good autocompletion. So just typing .

Continue Reading »

Ruby for Python Programmers

While I noted similarities and difference between Ruby and Python, as I was learning the basics here, here and here there is official document on the Ruby site. See this

Learning Ruby: Syntax (Part 3)

Methods Ruby functions start with def just like python, but end with end keyword. splat operator (*) to destructure an array into a List. This is similar to Python splat operator >>> x = [10, 20, 30] >>> a, *b = x >>> print(f'{a=}, {b=}') a=10, b=[20, 30] Python ☝️, Ruby 👇 >> first, *rest, last = ["a", "b", "c", "d"] => ["a", "b", "c", "d"] >> first => "a" >> rest => ["b", "c"] >> last => "d" >> But in Ruby, splat operator can also create an array.

Continue Reading »

Learning Ruby: Syntax (Part 2)

Learning continues … idiomatic(?) ruby loops use each like : (1..5).each do |counter| puts "iteration #{counter}" end Although python like loop also work for counter in 1..5 puts "iteration #{counter}" end array.each_with_index is like python’s enumerate Ruby seems to have multiple ways to do the same thing, as opposed to Python’s There should be one– and preferably only one –obvious way to do it. e.g. a.map do .. end, a.map { |el| e.

Continue Reading »

Installing Ruby

There are multiple ways to install ruby on your machine. Official recommendation is to use your OS’s package manager like apt, pacman or brew If you are using a version manager, rvm (Ruby Version Manager) seems to be popular. But in the past, I started using asdf, so I’ve decided to stick with it. It is also mentioned (first in the list) on the official Installing Ruby page 😄 asdf plugin add ruby https://github.

Continue Reading »

Learning Ruby: Syntax (Part 1)

I’ve meaning to learn Ruby for some time now. Especially, when I dabbled from time to time in Elixir, I felt that knowing Ruby may be an advantage (since Elixir syntax similar to Ruby) No one learns (I think) Ruby just for the language. They learn it so that they can use Ruby on Rails (RoR as popularly known) RoR, in case you don’t know, is the Web framework. Like Django in Python land.

Continue Reading »