Questions tagged [ruby-1.9]

Ruby 1.9 is a shortcut for ruby versions 1.9.1, 1.9.2 and 1.9.3. Ruby is a dynamic language that focuses on simplicity and expressiveness.

Ruby is a dynamic language that focuses on simplicity and expressiveness.

Ruby 1.9 is the successor of Ruby version 1.8, there are the subversions 1.9.1, 1.9.2 and 1.9.3. The successor Ruby 2.0 was published 2013-02-24.

Ruby 1.9 is incompatible with Ruby 1.8, the succcessor Ruby 2.0 is intended to be fully backward compatible with Ruby 1.9.3.

Ruby 1.9 introduced new features like:

  • Per-string character encodings are supported
  • Block local variables (variables that are local to the block in which they are declared)
  • An additional lambda syntax
  • New socket API (IPv6 support)
  • require_relative import security
429 questions
6
votes
3 answers

Multiple Forms on the Same Page with Rails

So I'm building a rails app for high school students and I've hit a problem when it comes to creating users. I want the students to only be able to create accounts if they select their school and type in their school's password correctly. What is…
Eric Koslow
  • 2,004
  • 2
  • 21
  • 33
6
votes
1 answer

Why does this code work in ruby 1.8 and not ruby 1.9?

This piece of code: def func *; end [func "hello"] is parsed without error in Ruby 1.8.7, but returns a syntax error: syntax error, unexpected ']', expecting '}' in Ruby >= 1.9. I looked through What is the difference between Ruby 1.8 and Ruby…
Aman Gupta
  • 557
  • 1
  • 8
  • 23
6
votes
1 answer

IRB - Ruby 1.9.x hash syntax: {if: true} is not equal to {:if => true}

Long story short, I was writing a method that included an options argument, that will do certain stuff if the value for the key :if, evaluated to true. When I trying the hash in IRB using the new syntax I got a syntax error in IRB, the prompt stays…
Leonel Galán
  • 6,993
  • 2
  • 41
  • 60
6
votes
5 answers

Ruby1.9 and Amazon SQS?

Is there a good library/gem for accessing Amazon SQS from ruby1.9? The Amazon ruby example and right_aws do not work as-is with ruby1.9. I'd strongly prefer something that's known to work under reasonably heavy load (a few hundred thousand queue…
fields
  • 4,433
  • 4
  • 27
  • 32
6
votes
2 answers

how do you start ruby 1.9 without rubygems

I want my app to not be able to use any installed gems. Is there a ruby 1.9 startup parameter or way of doing this programmatically?
rogerdpack
  • 62,887
  • 36
  • 269
  • 388
6
votes
1 answer

Why doesn't `block_given?` work in this dynamically-defined method?

When I write methods that take an optional block, I typically use something like block.call if block_given? However, in method defined dynamically like the one below, block_given? doesn't seem to work. class Foo %w[bar baz].each do |method_name| …
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
6
votes
2 answers

Ruby on Rails - can not install SystemTimer

I am using windows and I just ran the command: C:\Sites\cmply>gem install SystemTimer -v '1.2.3' and I got this error: Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing…
GeekedOut
  • 16,905
  • 37
  • 107
  • 185
5
votes
2 answers

Merging two hashes by concatenating the arrays

Given two hashes whose values are arrays, what is the best way to merge them so that when the two shares some key, the resulting value will be the concatenation of the values of the original two hashes? For example, given two hashes h1 and h2: h1 =…
sawa
  • 165,429
  • 45
  • 277
  • 381
5
votes
1 answer

Is it possible to get the successor and predecessor of a hash key in Ruby 1.9?

I wonder if something like this is possible without iterating over the whole hash: collection = { red: 1000, green: 120, "yellow" => 1, blue: 999 } Something like this: collection.next_key(:red) #Should return :green collection.prev_key(:blue) …
Daniel Rikowski
  • 71,375
  • 57
  • 251
  • 329
5
votes
1 answer

adding a char encoding to ruby 1.9.x?

If one wanted to add a new char encoding to 1.9.x, supported just the same as the built-in encodings, how would you go about doing it? Can you do it with code in ruby, or would it require a C patch in MRI? (I don't think it matters, but I am…
jrochkind
  • 22,799
  • 12
  • 59
  • 74
5
votes
1 answer

Ending ruby program if a given condition is met

Basically, I am just trying to stop the program from running the rest of the lines if a certain condition is met. unless raw_information.first puts "No results were returned for that query" break end However, before the program even runs I get…
user858642
  • 187
  • 2
  • 2
  • 6
5
votes
1 answer

Escape status within a string literal as argument of `String#tr`

There is something mysterious to me about the escape status of a backslash within a single quoted string literal as argument of String#tr. Can you explain the contrast between the three examples below? I particularly do not understand the second…
sawa
  • 165,429
  • 45
  • 277
  • 381
5
votes
5 answers

I'm learning to program and have chosen Ruby. Should I upgrade to Ruby 1.9?

I’m a complete non-programmer who is learning to program with Ruby and the Rails framework. I’m currently using Ruby 1.8.7 and Rails 3.0.3, but I’m wondering if I should upgrade to Ruby 1.9 since I don’t really have any “legacy” costs with…
Brennan
  • 71
  • 4
5
votes
2 answers

Ruby 1.9 slower than Ruby 1.8?

I have a Rails 2.3.8 app with an action that pulls a large amount of data from a database and renders it with anywhere from 300-600 partials (recursively rendering a tree-type structure). Benchmarking one request gives me response times of about 7…
Jimmy Z
  • 723
  • 1
  • 5
  • 18
5
votes
3 answers

Ruby 1.9 strip not removing whitespace

Im doing some screen scraping and im getting back a string that appears to end with whitespace but neither string.strip or strip.gsub(/\s/u, '') removes the character. Im guessing it's a character encoding issue. Any suggestions?
Sam
  • 6,240
  • 4
  • 42
  • 53