Skip to content

Part 0: Ruby Basics

Andy Meneely edited this page Nov 3, 2015 · 9 revisions

(This page is just a sketch of what is to come. Feel free to contribute if you like.)

I'm not a programmer, but I want to use Squib. Can you make it easy for non-programmers?

If you want to use Squib, then you want to automate the graphics generation of a tabletop game in a data-driven way. You want to be able to change your mind about icons, illustrations, stats, and graphic design - then rebuild your game with a few edits. You want to give a list of instructions to a computer, and have it execute your bidding.

If you want those things, then I have news for you. I think you are a programmer. And maybe Squib will be your excuse to finally learn how to do some coding.

Squib is a Ruby library. To learn Squib, you will need to learn Ruby. There is no getting around that fact. Don't fight it, embrace it.

Fortunately, Squib doesn't really require tons of Ruby-fu to get going. And I've done my best to keep to Ruby's own philosophy that programming in it should be a delight, not a chore.

Doubly fortunately, Ruby is wonderfully rich in features and very expressive in its syntax. Ruby has a vibrant, friendly community (much like tabletop game designers!). Ruby is the language of choice for many new programmers, including many universities. On the flip side, Ruby is "industrial strength", so it really can do just about anything you need it to. Plus, resources for learning how code is ubiquitous on the Internet.

In this article, we'll go over some topics that you will undoubtedly want to pick up if you're new to programming or just new to Ruby.

What You DON'T Need To Know for Squib

Let's get a few things out of the way. When you are out there searching the interwebs for solutions to your problems, you will not need to learn anything about the following things:

  • Rails. Ruby on Rails is a heavyweight framework for web development (awesome in its own way, but not relevant to learning Ruby). Squib is about scripting, and will never be a web app.
  • Object-Oriented Programming. While OO is very important for developing long-term, scalable applications, some of the philosophy around "Everything in Ruby is an object" can be confusing to newcomers. It's not super-important to grasp this concept for Squib. This means material about classes, modules, mixins, attributes, etc. are not really necessary for Squib scripts. (Contributing to Squib, that's another matter.)
  • Metaprogramming. Such a cool thing in Ruby... don't worry about it for Squib.

What you need to know about Ruby for Squib

  • Understand scripting
  • What do and end mean
  • Ruby Arrays, so that the range parameter makes more sense
  • Strings, variables, and symbols
  • If you are using Excel or CSV, then Ruby hashes are worth a glance.
  • Editing Yaml. Yaml is not Ruby per se, but it's a data format common in the Ruby community and Squib uses it in a couple of places (e.g. layouts and the configuration file)

Other Important Programming Skills

  • Command line basics
  • Edit-Run-Check. (i.e. working iteratively). making small edits and run your code frequently (every few minutes)
  • Getting a good text editor

Ruby Learning Resources

Ruby's Own Website: Getting Started This will take you through the basics of programming in Ruby. It works mostly from the Interactive Ruby shell irb, which is pretty helpful for seeing how things work and what Ruby syntax looks like.

Clone this wiki locally