Questions tagged [ruby-1.8]

For issues relating to developing in Ruby, version 1.8. If your question applies to Ruby in general, use the tag [tag:ruby].

Ruby is an open-source dynamic object-oriented interpreted language created by Yukihiro Matsumoto (Matz) in the 1990s.

Related tags:

140 questions
1
vote
2 answers

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 ?
horseyguy
  • 29,455
  • 20
  • 103
  • 145
1
vote
2 answers

How to count duplicates hash itens in Ruby 1.8.5 ( Sketchup Ruby API )

I need to count the duplicates, they need to be 100% identical to increase my count, but I can not use a nothing out of Ruby 1.8.5, this code will run inside a plugin in google sketchup Google Sketchup Ruby API puts VERSION 1.8.5 puts…
romuloigor
  • 182
  • 1
  • 11
1
vote
2 answers

How to match regexp starting from specific character index in Ruby 1.8?

In Ruby 1.9 I would use String#match(regexp,start_index). I'm sure there must be a (computationally efficient) equivalent in Ruby 1.8, but I can't find it. Do you know what it is?
Alex D
  • 29,755
  • 7
  • 80
  • 126
1
vote
2 answers

missing '=>' in ruby irb results

I'm reading an eBook for EXTREME beginners in Ruby. It's walking me through VERY step-by-step, but I want to make sure I'm doing it right before I move on. My first problem was when I typed irb. Instead of getting irb(main):001:0> like I was…
regan_leah
  • 284
  • 2
  • 3
  • 14
1
vote
1 answer

Rails inserting invalid datetimes in created_at and updated_at

I am using Rails 3.2.2 on Ruby 1.8.7 with mysql2 0.3.11 (against a mysql 14.14 server), and sometimes a created_at or updated_at value will be an invalid DateTime, and cause my app to throw an exception with the message "Invalid date: 2022-03-00…
LukeShu
  • 75
  • 1
  • 7
0
votes
1 answer

String#pack works on 1.9+, not 1.8*

I stumbled upon an error that I don't quite understand. # Ruby 1.8.7 >> [Digest::MD5.hexdigest("http://www.google.com").to_i(16)].pack("N") RangeError: bignum too big to convert into 'unsigned long' # Ruby 1.9.3 >>…
ksol
  • 11,835
  • 5
  • 37
  • 64
0
votes
5 answers

Sorting Values within Hash (with Sphinx facets)

I am using Sphinx to return a hash of facets. The hash returned is like so: {:brand=>{"C Brand"=>170, "A Brand"=>17, "B Brand"=>160}, :store=>{"B Store"=>95, "C Store"=>1, "A Store"=>9}} The hash contains the name of the store/brand, along with the…
tob88
  • 2,151
  • 8
  • 30
  • 33
0
votes
2 answers

Read Integer within a String

I need to somehow read an integer within a string. The string will be as follows; GAME_SWITCH(476) And I need to read the 476 part. Note, it won't be 476 each time, but it will be "GAME_SWITCH(...)" each time. I've tried using the .delete methods…
HarryE
  • 17
  • 5
0
votes
1 answer

Error while mounting sinatra application in rails

I have a rails application that in turn uses sinatra app in it. I added this line to routes mount TestApp::Application => "/test_app" now while accessing /test_app routes it gives TypeError (no marshal_dump is defined for class Mutex) if ran…
ducktyped
  • 4,354
  • 4
  • 26
  • 38
0
votes
1 answer

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…
Robert K
  • 30,064
  • 12
  • 61
  • 79
0
votes
2 answers

Ruby-FFI (ruby 1.8): Reading UTF-16LE encoded strings

I am working with Ruby-FFI on Ruby 1.8 to wrap a library that uses UTF-16LE strings. The library has a C function that returns such a String. Whether I wrap the function with attach_function [:getVersion, [], :pointer] and call read_string on the…
mydoghasworms
  • 18,233
  • 11
  • 61
  • 95
0
votes
3 answers

Hash merging behavior

Is this behavior correct? I'm running some code like the following: @a_hash = {:a => 1} x = @a_hash x.merge!({:b => 2}) At the end of all that, x's value has been changed as expected but so has the value for @a_hash. I'm getting {:a => 1, :b => 2}…
blim8183
  • 768
  • 1
  • 8
  • 23
0
votes
1 answer

Installing ruby 1.8.7 with ruby 1.9.2

I have ruby 1.9.2 installed on my system (Ubuntu) using rvm, but one application needs rvm 1.8.7, How shall I install ruby 1.8.7 along with ruby 1.9.2 amd run on my system . Please guide ?
Metal
  • 205
  • 3
  • 11
0
votes
1 answer

Adding method to class in Ruby

I am trying to add a method to Observable, so that for a class that includes it, it can call the method observe_attribute :attribute that would generate a method attribute= with the logic to check to see if the value has changed: module Observable …
TheDude
  • 3,796
  • 2
  • 28
  • 51
0
votes
1 answer

Rails 3 - link_to image in ruby 1.8 and 1.9

I have upgraded my localhost version of ruby from 1.8.7 to 1.9.2 and I got some errors in my templates. For example, in ruby 1.8.7 I use following: <%= link_to ((image_tag 'image.png', :alt => 'bla bla bal'), url_for(root_url), :id…
user984621
  • 46,344
  • 73
  • 224
  • 412