Useless Ruby Gems for your pleasure

| Posted: - Last updated:
| Tagged blog ruby on rails
| ~400wrds (~2min)

The past few days I’v taken some time to find out how to create a Ruby Gem. This has been on my to-do list for quite a while, but now I’m able to tick it off.

Well, what did I make?

The first Gem can also be used as a Ruby on Rails plugin and is called ActsAsGold. If you’ve ever played World of Warcraft, you’ll know how the money system works. You have Copper. A 100 Copper is worth 1 Silver. And 100 Silver is worth 1 Gold.

The ActsAsGold Gem allows you to extend your ActiveRecord model with this money system. All you need on your model is an attribute that stores a single integer value.

Let me give you a small tour.

class Player < ActiveRecord::Base
  acts_as_gold :column => :money

# This will be store like => 2003652 => 200
@player.silver => 36
@player.copper => 52

# You can also easily earn or spend money
@player.earn( + 75.silver)
@player.spend( + 10.silver + 95.copper)

Read more about the Gem, or install the gem right now:

sudo gem install ariejan-acts_as_gold --source

The other gem is WarcraftArmory, which is still in early development, so new stuff can and will be added in the future.

WA (WarcraftArmory) allows you to easily retrieve character information from the World of Warcraft Armory. Currently it can retrieve:

  • Name of the character
  • Name of the characters guild
  • Level
  • Race
  • Class

It works for both EU and US warcraft servers.

require 'warcraft_armory'

character = WarcraftArmory.find(:eu, 'Aszune', 'Nosius')

character.race => "Human"
character.level => 15

Again, simply install the plugin and use it like any other gem or read the README first.

sudo gem install ariejan-warcraft_armory --source

Of course, these gems are released under the MIT license. The code is on Gitub (acts_as_gold, warcraft_armory) and patches with fixes and new features are gladly accepted.

Please let me know if you find these gems useful or if you use them in one of your projects.

My site is free of ads and trackers. I record privacy-respecting usage statistics with Fathom.

Was this post helpful to you? Why not ☕ Buy me a coffee or use Brave Browser to send a tip.