

Useless Ruby Gems for your pleasure
source link: https://www.devroom.io/2008/08/14/useless-ruby-gems-for-your-pleasure/?utm_campaign=Feed%3A+ariejan+%28ariejan%7Cdevroom.io%29
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Useless Ruby Gems for your pleasure
Posted:
2008-08-14
- Last updated:
2019-06-05
Tagged blog ruby on rails
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 end # This will be store like @player.money => 2003652 @player.gold => 200 @player.silver => 36 @player.copper => 52 # You can also easily earn or spend money @player.earn(10.gold + 75.silver) @player.spend(1.gold + 10.silver + 95.copper)
Read more about the Gem, or install the gem right now:
sudo gem install ariejan-acts_as_gold --source http://gems.github.com
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
- 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 http://gems.github.com
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.
Recommend
-
75
Ohai Emacs While it is certainly true that Emacs is the most powerful text editor in the world, your first impression of it may be less favourable, because its default configuration really just isn’t all that great. But now there i...
-
8
Ruby is not only a fun language, it also comes with an excellent standard library. Some of which are not that known, and are almost hidden Gems. Today guest writer Michael Kohl highlights a favorite: Stringscanner. Ruby’s hidden Gems...
-
12
Ruby Magic Ruby's Hidden Gems: Delegator and Forwardable Michael Kohl on Apr 30, 2019 “I absolutely love AppSignal.” Discover...
-
8
16 New ML Gems for Ruby In August, I set out to improve the machine learning ecosystem for Ruby and wasn’t sure where it would go. Over the next 5 mo...
-
6
Using Bundler to install Ruby gems Overview If your Ruby application won't start because of a missing gem, then you must install it locally using Bund...
-
11
Ruby's Hidden Gems: Bullet Fabio Perrella on Aug 11, 2021 “I absolutely love AppSignal.” Discover AppSignal A database is th...
-
2
What's Your Favorite Guilty Pleasure in Film, TV or Music?February 10th 2022 new story4Zaeem Shoaib,...
-
6
A definitive guide to Ruby gems dependency managementLiran TalAugust 4, 2022Ruby, much like other programming languages, has an entire ecosystem of third-party open source libraries which it refers to as gems...
-
8
Ruby's Hidden Gems -Delegator and ForwardableMichael Kohl on Apr 30, 2019
-
4
Authorization Gems in Ruby: Pundit and CanCanCanAestimo Kirina on Mar 22, 2023
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK