ruby1.8

Ruby 1.8 and UTF-8 string case statment compare (Ruby on Rails 2.2)

Hello :) I have a rake task (in lib/tasks directory) that I run with cron on my shared web hosting. The problem is that I want to compare a UTF-8 string using case statment but my source code is not UTF-8 encoded. If I save source code as UTF-8 there is error when I try to start it :( What I have to do? May be read this strings from ...

Unreproducible string comparison, forces elsif failure.

In answering this code golf question, I ran across a problem in my answer. I've been testing this and I cannot even get these two comparisons to work in the code, despite the fact that IRB has the right behavior. I really need some help here. Here's the code, below that will be an explanation of the problem. def solve_expression(expr...

(Ruby) Getting Net::SMTP working with Gmail...?

Hi All, Does anyone have any quality (and up-to-date) information regarding sending mail via Gmail using Ruby's Net::SMTP? I've seen several examples -- most dating from 2007 to mid-2008 and none of them work for me. I need more current examples that use the most recent 1.8.7 release. I'd also appreciate if the documentation didn't o...

Differences in instance_eval behaviour between Ruby 1.9.1 and 1.8.6 ?

I noticed that class variables @@my_class var are now looked up in the context of the instance_eval'd object in Ruby 1.9.1 whereas this was not the case in Ruby 1.8.6. What are some other differences in behaviour of instance_eval for Ruby 1.9.1 ? ...

Ruby Array#puts not using overridden implementation?

I am using Ruby 1.8.6 for the following code: # Create an array and override the #to_s on that object thing = [1,2,3] def thing.to_s 'one' end print "Using print: " print thing puts puts "Using puts: " puts thing Output: Using print: one Using puts: 1 2 3 So thing is an Array and I have overridden thing#to_s. print seems to us...

How to get code of unicode character using Ruby 1.8.6?

If I add this to the beginning of my script: $KCODE = 'UTF8' require 'jcode' then I can walk over every char of a word containing unicode characters. Imagine a word containing umlauts or something, and I iterate over them like this: word.each_char do |c| # do something with c end If c is a unicode character and I print it's size,...

Is there a fast and reliable way of serializing objects across different versions of Ruby?

I have two applications talking to each other using a queue, as of now they run exactly the same version of ruby (1.8.7), so I'm just marshaling objects back and forth; only objects from the standard lib mostly hashes, strings, time and date objects. Right now I'm moving to Ruby 1.9.1, one app at the time, which means I'll be running o...

How do I use Ruby's SOAP::Attachment class?

So I'm writing a Ruby client for a SOAP web service, and I've figured out how to call a simple method: # WebServiceClient.rb require 'soap/wsdlDriver' wsdl_url = 'http://urlmadness?wsdl' service = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver result = service.simpleMethod(:sayHello => 'Hello') p result.return Now I need t...

What's discouraging you from writing ruby 1.9-specific code?

So far, I've been merely using YARV (ruby 1.9) as merely a faster implementation of ruby than ruby 1.8, and ensured that all of my code is backwards-compatible with ruby 1.8.6. What circumstances, if any, are stopping you from writing 1.9-specific code? One reason per answer. ...

How to update Ruby in Google SketchUp?

Currently Google SketchUp for Mac has Ruby version 1.8.5 which I find a bit outdated. I can update Ruby to 1.8.7 (OSX's version) by the following commands $ cd /Applications/Google\ SketchUp\ 7/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/Current $ ls Headers/ Resources/ Ruby $ ls Headers/ config.h defines.h inter...

Comparing two similar hashes in ruby

I'm using ruby 1.8.7 and I need to compare two hashes that I have, which are essentially the attributes of a model. Hash A is smaller than Hash B, and Hash B has all of the attributes of hash A, plus some extra attributes I don't care about. My overarching goal is to see if the elements of A are the same as the respective elements of B...