Below you will find pages that utilize the taxonomy term “Ruby”
Why Do I Have to Use the Factorybot Gem, Again?
The FactoryBot gem, previously known as FactoryGirl, is ubiquitous in Ruby and Ruby on Rails testing. If you aren’t familiar with it, you might be wondering, what’s the point? Wouldn’t it be simpler to just build objects myself?
Hash Fetch Instead of If/Else
Conditional logic has its place, but often there’s a better alternative.
Today, we’ll look at a Ruby solution: a hash with .fetch
.
RSpec.describe vs. describe: Which Should I Use?
Ruby’s RSpec describe
block has two common syntaxes. Which should you use?
Ruby's Frozen String Comment: YAGNI
Open a production Ruby file, and you’ll often see this magic comment at the top.
# frozen_string_literal: true
Today I’d like to argue that most Ruby files do not need this comment. You aren’t going to need it.
Augmenting an Object With the Proxy Pattern
Let’s look at the proxy pattern in Ruby.
Binary to Decimal Conversion in Ruby
This week I wrote an algorithm in Ruby to convert binary numbers into decimal numbers. Here’s the problem description, from Exercism:
“Convert a binary number, represented as a string (e.g. ‘101010’), to its decimal equivalent using first principles. Implement binary to decimal conversion. Given a binary input string, your program should produce a decimal output. The program should handle invalid inputs.”
Porting TIL from Rails to Phoenix: Initial Commits
Last week, I started a new project: porting Today I Learned from Ruby on Rails to Phoenix (Elixir).
Server Side Sorting in Ruby
Recently a friend asked me this question about server-side sorting in Rails. Here’s the question and my answer.
From One End to the Other in Ruby
A while back I tackled the following programming challenge:
From One End to the Other: Find the smallest possible (positive) integer that ends in a six such that if that six is removed and placed in front of the remaining digits of the number, the resulting number will be four times as large as the original.
LED Clock in Ruby
A few weeks ago I built a program to display an LED clock. Here’s the problem, and my solution.
Ceramic Nation
Project announcement! Last night I built a Markov Chain-generated novel, titled Ceramic Nation.
Code Club: Rack and Rails Server
This week in Code Club we explored Rack, the middleware of the Rails stack. Rack is newsworthy of late due to a change in ownership, prompting inevitable questions about the future. As Rails developers, we wanted to know what Rack really does.