# Crafting Code: Building a Ruby Pattern Generator for a Crochet Circle

DevFeed: [Crafting Code: Building a Ruby Pattern Generator for a Crochet Circle](<https://devfeed.tech/articles/crafting-code-building-a-ruby-pattern-generator-for-a-crochet-circle-20114.md>)

Original publisher: [Read original article](<https://hashrocket.com/blog/posts/crafting-code-building-a-ruby-pattern-generator-for-a-crochet-circle>)

Author: Mary Lee

Published: 2026-01-20T14:00:00Z

Content type: tutorial

Language: en

Sources: [Hashrocket](<https://devfeed.tech/sources/hashrocket.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [Parsing](<https://devfeed.tech/topics/parsing.md>), [Parser](<https://devfeed.tech/topics/parser.md>), [Code](<https://devfeed.tech/topics/code.md>), [coding](<https://devfeed.tech/topics/coding.md>)

Tags: [building](<https://devfeed.tech/tags/building.md>), [code](<https://devfeed.tech/tags/code.md>), [coding](<https://devfeed.tech/tags/coding.md>), [parsing](<https://devfeed.tech/tags/parsing.md>), [patterns](<https://devfeed.tech/tags/patterns.md>), [project](<https://devfeed.tech/tags/project.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [side-projects](<https://devfeed.tech/tags/side-projects.md>)

## AI overview

This tutorial describes building a Ruby class that generates crochet circle patterns. It explains how crochet rounds are formatted, how stitch abbreviations and counts reveal repeated increases, and how those patterns can be parsed and modeled in code.

## Source excerpt

In my time as a developer, I have noticed that one of the most common ways my coworkers spend time coding outside of work is by developing little code snippets or apps that solve problems in their everyday lives. From household budgeting, to managing workouts on rowing machines, to generating a Taco Bell order, these projects allow devs to explore different coding styles and learn new technologies. For a long time, most of my side projects have been for the sole purpose of learning a new technology. When I wanted to start building mobile apps with React Native, I wrote a small to-do app that, once finished, I abandoned. The same thing happened when I wanted to try to use PostgreSQL's listen and notify feature to build a live updating chat app. So, when I was thinking about a new side project, I decided it was time to work on something that could be long lived and help me with one of my favorite hobbies: crocheting. The Premise Recently, I've been making a lot of small projects that have started with a base shape that then gets built upon. Often, this shape is a circle. After running through several projects, I started to notice a pattern of increases and repetitions for each row. It occurred to me that if the shape followed a specific pattern, I could probably build a ruby class to generate that pattern. Thus began this side project! Breaking Down a Simplified Pattern To begin, we have to inspect the pattern. Crochet patterns follow a specific format, and use abbreviations for the types of stitches being used. The example pattern uses the following abbreviations and rules: Abbreviation Meaning Use Stitch Count sc single crochet adds a stitch to the round 1 inc increase (two single crochets in the same stitch) adds an extra stitch to the round 2 With those abbreviations in mind, we can start parsing the pattern. R1: 6sc in magic ring (6) R2: [inc] x6 (12) R3: [sc, inc] x6 (18) R4: sc, inc, [2sc, inc] x5, sc (24) R5: [3sc, inc] x6 (30) R6: 2sc, inc, [4sc, inc] x5, 2sc