Simple Translation Gem I have a small gem that I've been maintaining. This gem provides a simple way to do translation using an alternative Google API.

I've been working with Java last year and recently did some refactoring on that gem, but I don't think it's Rubyist enough.

require_relative 'extractor'
require_relative 'requester'
require_relative 'translator'

module FreeGoogle
  ##
  # Responsible for create instance of {FreeGoogle::Translator}
  # It holds all dependencies for this creation
  class Factory
    def self.create
      extractor = FreeGoogle::Extractor.new
      http_requester = FreeGoogle::Requester.new
      FreeGoogle::Translator.new(extractor, http_requester)
    end
  end
end


Source code

Are factories commonly used in Ruby?
It's hard to say much about such a short code sample, but factories simply encapsulate object creation (wiring up objects), which frees code using them from that responsibility.  In that sense, factories are relevant in ruby too.

However, note that client code would look like this, given your current code:

translator = FreeGoogle::Factory.create


which isn't as readable as it could be.  I think I'd prefer to write something like the following in my client code:

translator = FreeGoogle.new_translator