ruby

Learn Go Or Improve My Python/Ruby Knowledge

I was reading about Go, and I can see that it's very good and can be a language used by many developers in some months, but I want to decide a simple thing: Learn Go or improve my Python or Ruby knowledge? Years developing with Python: 1 Years developing with Ruby: 0.3 ...

Ruby equivalent to Python's help()?

When working in interactive python, I tend to rely on the builtin help() function to tell me what something expects and/or returns, and print out any documentation that might help me. Is there a ruby equivalent to this function? EDIT I'm looking for something I could use in irb. For example in interactive python I could type >>> help(1...

How to acess ctime, mtime, … of a symbolic link?

On unix symlinks are pointers to another file. Not only the file but also the symlink has a ctime, mtime, …. I know the symlinks time can be accessed, as ls displays it. If I use one of ruby's File#ctime, File#mtime, …, I always get the attribute of the file the symlink is pointing to, not of the symlink. How can I read this values in ru...

Procedural generation algorithms in Ruby

Greetings! As part of Ruby learning, I am working on a project that involves procedural generation, namely terrain generation and such. It happens to be in Ruby, however after the long weeks of searching and experimenting I am turning to you lot with the question or, more accurately, a plea. This is a two-fold question. Are there any ...

How do I do an Intersection of many<-->many DataMapper Collection?

I am trying to return an intersection of datamapper collections relating to tagged topics. Before we go any further I should point out the obvious: @tags = Tag.all(:title => ["shim", "sham"]) @tags.topics This returns a UNION which means I get all topics with either 'shim' or 'sham' as a tag. What I want to do is return all articles...

Starting with Ruby 1.9.x, Rails 3, and/or Merb

I need to spend some serious time reading about changes in Ruby 1.9.1 and upcoming Rails 3/Merb. Can people suggest any articles to read? Not really looking for one answer, just kinda looking for a compilation of resources people are using to keep up with what's coming and what currently exists, so if you stop by, let me know what you'r...

Best GUI Framework for Ruby. Not Shoes.

Hello everyone. I am trying to settle on a GUI framework for Ruby and I have yet to decide which one I prefer and would like some input. I mainly want to pick the framework with the most support and community involvement. I have shied away from Shoes because the site is down and because I would like some challenge and understanding of w...

Are there any GOOD Chef, Chef-Server and Chef-Client tutorials out there?

Hi there, Chef from Opscode seems to be really useful for configuring servers and such, but trying to follow their documentation is a little difficult. Some terms are defined after they are used, and definitions sometimes reference new terms that you haven't yet encountered. Anyone know of any GOOD tutorials/walk-throughs for getting a ...

API integration with Rails or Other Language

Hi All, I need the API integration for the following site 1] alamo car service 2] avis car service 3] thrifty car service 4] hertz car service If any one know anything regarding any of the above please reply. Regards, Salil ...

Built in way to list directories in a directory in ruby

Is there a cleaner built-in way to do this? ree> Pathname.new('/path/to').children.select{|e| e.directory?}.map{|d| d.basename.to_s} => ["test1", "test2"] Ideally I would like to avoid the directory? call ...

Undefine variable in Ruby

Let's say I'm using irb, and type a = 5. How do I remove the definition of a so that typing a returns a NameError? Some context: later I want to do this: context = Proc.new{}.binding context.eval 'a = 5' context.eval 'undef a' # though this doesn't work. ...

Python or Ruby for web development?

I'm a web developer proficient in HTML, CSS and Javascript, but to be able to develop my own web applications, I'd like to learn a programming language besides PHP. I've been learning Python for a while now but it seems a general purpose language, a bit complex, and not suited for web-development I guess. So if my focus is creating we...

Ruby Unit Test : Is this a Valid (well-formed) XML Doc ?

I'm creating an XML document: I want to unit test at least to make sure it's well-formed. So far, I have only been able to approximate this , by using the 'hasElements' in the REXML library. Is there a better way ? Preferably using built-in libraries (I mean libraries that ship with the standard Ruby 1.8.x distro). require "test/unit"...

don't understand few lines ruby codes

Hi, I'm working on a ruby on rails project which is developed by someone else rails expert. I don't know ruby well. So while i modifying the existing project, i could not fix a bug because i didnt understand few lines code. It will be great if someone explain. Here are the codes - on my home controller - home_controller.rb class Home...

Setting up local web server on Mac for Ruby on Rails

I use MAMP for PHP/MySQL. What do I need for RoR? I am using OS X Leopard. I have already installed Ruby, Gems and Rails. ...

RoR: how to use other obj outside my own folder?

I found that I only can @products in the views/products/ folder, I can't call the @products in other position, like views/store ..... .... If I want to use the @products in the view/store, wt should I do? apart from calling /views/products. ...

Ruby on Rails: Aggregating several columns into an Array

I'm developing a Ruby on Rails app where one of my database tables has 10 columns (pile_1 through to pile_10). It would be convenient to access these columns in the model as a 10-element Array. It feels like I should be able to coerce composed_of into doing what I want, but I can't figure out how. Can anyone enlighten me, or suggest a b...

Ruby: Nicer way of doing this : script to run against stdin if no arg; otherwise input file =ARGV[0].

This works quite nicely - just wondered if there are any improvements to shorten it ? if (ARGV[0].nil?) then input=$< else input=File.new(ARGV[0],"r"); end ... # Do something with the input here, for example: input.each_line do |line| puts line end ...

<%= debug(controller) %> produces unreadable output

In one of my templates I want to take a closer look at the controller object using the debug() helper. It is said to produce YAML suitable for HTML output. Running <%= debug(controller) %> does, however, not produce anything I call readable. It begins with: #<ClubsController:0x104467378 @_request=#<ActionController::Request:0x1044676...

Using factory_girl in Rails with associations that have unique constraints. Getting duplicate errors.

I'm working with a Rails 2.2 project working to update it. I'm replacing existing fixtures with factories (using factory_girl) and have had some issues. The problem is with models that represent tables with lookup data. When I create a Cart with two products that have the same product type, each created product is re-creating the same pr...