ruby

Ruby IDE for windows with autocompletion for my user defined classes

Is there a Ruby IDE for windows that supports auto completion for user defined classes (like textmate does)? class MyClass attr_accessor :name, :age def initialize(name, age) @name, @age = name, age end end mc = MyClass.new mc.... The last line should list [name, age] ...

How can I handle large files in Ruby?

I'm pretty new to programming, so be gentle. I'm trying to extract IBSN numbers from a library database .dat file. I have written code that works, but it is only searching through about half of the 180MB file. How can I adjust it to search the whole file? Or how can I write a program the will split the dat file into manageable chunks? e...

How to look up elevation data by lat/lng

I am planning an app that will need the ability to look up the elevation of geographic points by lat/lng. Ideally I would like something that would work worldwide, but US-only would also suffice. I have looked at using the USGS Elevation Query Web Service, however it only allows you to query for one point at a time, and I will need to lo...

When and where to implement ACL.

I've got rails_authorization_plugin up and running with models. What's the best way to implement permission checks on my site? I have complicated conditions for when an instance of an object should be visible, is there an efficient way to chain them together so I'm not fetching multiple sets of data and grinding my DB as a result of lo...

How do I get the last SQL query performed by ActiveRecord in Ruby on Rails?

I'm looking for something like CodeIgniter's: $this->db->last_query(); (http://codeigniter.com/user_guide/database/helpers.html) ...

Rewrite a ruby class on the fly

Hi there, I'm using HighLine to write my console application and I would like to modify the HighLine::Question::in_range! function so that tab completion stayed activated but that highline do not bother checking if the words typed are in the range. So let's say I have a tab completion list like %w{app1, app2, app3} I'd like to be able...

restful_authentication nothing appears

I have followed the basic instalation ( http://railscasts.com/episodes/67-restful-authentication ) Doing this: 1.) ruby script/generate authenticated user sessions 2.) ruby script/generate authenticated user sessions and rake db:migrate 3.) On the file application_controler.rb I have included include AuthenticatedSystem 4.) On t...

what Ruby knowledge should I have?

I just discovered the what c# knowledge should I have? question and wondered about the same, but for Ruby. I consider Ruby to be my favorite programming language, and beyond learning the basics, at least what I've picked up from numerous Ruby on Rails projects and a few Ruby scripts, I've tried to learn from reading blogs like Gluttonou...

Run Shoes gui app in IDE

Is there any way to write Shoes application using IDE (NetBeans for example)? I hadn't found this solution and I don't like running Shoes app, selecting files, run. I'm sure code for packing Shoes and IDE code will be different (I hope in require directives only), but I'm intresting in possibility. ...

Objective-C string manipulation

Currently I am working on a piece of software, which is currently written 100% in Objective-C using the iPhone 3.0 SDK. I have come to a cross roads where I need to do quite a bit or string concatenation, more specifically, NSString concatenation and so far I have been doing it like this: Objective-C string concatenation: NSString *re...

Ruby with Qt

I'm working on a multi form Ruby-Qt program using, and I'm having a problem with controlling secondary windows from the primary one. How can i disable the primary window when any secondary one is open, also how to take a secondary window output to use it on the primary one, and finally, sorry this is a silly one, what is the appropriate ...

Is there a difference between the ways of defining a Ruby class method?

Given the following two ways of defining a class method in Ruby: class Foo class << self def bar # ... end end def self.baz # ... end end Is there a difference between the two? Is one more preferable than the other? ...

Parsing a String in Ruby (Regexp?)

I've got a string Purchases 10384839,Purchases 10293900,Purchases 20101024 Can anyone help me with parsing this? I tried using StringScanner but I'm sort of unfamiliar with regular expressions (not very much practice). If I could separate it into myarray[0] = {type => "Purchases", id="10384839"} myarray[1] = {type => "Purchases", id...

how to implement curry(partial function) in ruby

I need some examples of implementing curry function in ruby(1.8.6 or 1.8.7 not 1.9). ...

How do I get access to PUT data with the ramaze framework?

I'm attempting to use Ramaze, the ruby framework, to implement a RESTful controller. I can't seem to gain access to the data in the request when I send a PUT, however. Sample code: require 'ramaze' class PutController < Ramaze::Controller map '/' def index "Argument of "+request[:id] end end Ramaze.start And my interactin...

Is it OK to use Ruby 1.8.5?

I'm setting up a new RedHat Enterprise Linux 5 system to host Ruby apps running under Apache with Phusion Passenger. I've updated all the local packages on the system. Here is what RedHat is giving me for Ruby: $ ruby -v ruby 1.8.5 (2006-08-25) [i386-linux] That's pretty old. Is it better to use what RedHat provides or install a newer...

Reading a zip file from a GET request without saving first in Ruby?

I am trying read zip file from HTTP GET request. One way to do it is by saving the response body to a physical file first and then reading the zip file to read the files inside the zip. Is there a way to read the files inside directly without having to save the zip file into a physical file first? My current code: Net::HTTP.start("cl...

Multiple-Inheritance type class inheritance in ruby

I got a Base superclass and a bunch of derived classes, like Base::Number, Base::Color. I'd like to be able to use those child classes as if I they inherited from say Fixnum in the case of Number. What's the best way to do this, while still having them respond appropriately to is_a? Base ? So, I should be able to do Number.new(5) + N...

Removing one of the many duplicate entries in a habtm relationship?

For the purposes of the discussion I cooked up a test with two tables: :stones and :bowls (both created with just timestamps - trivial) create_table :bowls_stones, :id => false do |t| t.integer :bowl_id, :null => false t.integer :stone_id, :null => false end The models are pretty self-explanatory, and basic, but here they are: ...

Thin Crashes Hard with Ramaze

So, I'm just trying out Ramaze for a new project, and I'm wondering why it won't work with Thin, but will with ramaze start (which is webrick I guess). Here's what it gives me: /opt/local/lib/ruby1.9/gems/1.9.1/gems/thin-1.2.2/lib/thin/request.rb:50: [BUG] unknown type 0x22 (0xc given) This is the line it's talking about: @parser = ...