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
30
votes
4 answers

What is ARGF.class in Ruby 1.9?

In Ruby 1.8.7, the documentation does not list ARGF under classes and modules, and ARGF isn't a class or a module: ARGF.class # => Object In Ruby 1.9.3, the documentation has ARGF under classes and modules, but I see this: ARGF.class # =>…
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
29
votes
3 answers

Append row to csv file Ruby 1.9 CSV lib

Using Ruby 1.9 and CSV lib, I can't seem to append a row. The example in the documentation opens the file, and overwrites the row. What is the correct way to append rows to the document? Example from documentation: require…
cheolho minale
  • 299
  • 1
  • 3
  • 5
28
votes
4 answers

Is there a way in ruby 1.9 to remove invalid byte sequences from strings?

Suppose you have a string like "€foo\xA0", encoded UTF-8, Is there a way to remove invalid byte sequences from this string? ( so you get "€foo" ) In ruby-1.8 you could use Iconv.iconv('UTF-8//IGNORE', 'UTF-8', "€foo\xA0") but that is now deprecated.…
StefanH
  • 413
  • 1
  • 5
  • 7
24
votes
2 answers

How do I compare two files in Ruby 1.9?

In Ruby 1.8, I would call File.compare() from the "ftools" library to easily compare the contents of two files. However, in Ruby 1.9, "ftools" is replaced by "fileutils", which doesn't have a "compare" method. What's the equivalent call?
Craig Walker
  • 49,871
  • 54
  • 152
  • 212
24
votes
1 answer

How can I get Qt4 running with ruby 1.9.2 on Windows 7?

Summary I'm writing a Ruby 1.9.2 app using Qt4 for its GUI which I want to distribute on Linux, OS X and Windows. I have the app running fine on everything except my Windows 7 64-bit box. There are working examples of Win7 + Qt4 + 1.8.7, but…
Max Cantor
  • 8,229
  • 7
  • 45
  • 59
23
votes
8 answers

How do I get the class of a BasicObject instance?

I have a script that iterates using ObjectSpace#each_object with no args. Then it prints how many instances exist for each class. I realized that some classes redefine the #class instance method, so I had to find another way to get the actual…
Kelvin
  • 20,119
  • 3
  • 60
  • 68
23
votes
1 answer

What is the use or effect of freezing Symbols and Numbers in Ruby?

In Ruby 1.9 you can have Fixnum, Float, and Symbol values that are unfrozen or frozen: irb(main):001:0> a = [ 17, 42.0, :foo ]; a.map(&:frozen?) => [false, false, false] irb(main):002:0> a.each(&:freeze); a.map(&:frozen?) => [true, true, true] I…
Phrogz
  • 296,393
  • 112
  • 651
  • 745
23
votes
4 answers

str.each in Ruby isn't working

I'm Learning Ruby. I found the method String#each at http://ruby-doc.org/core/classes/String.html. When I try using it... irb(main):001:0> "hello\nworld".each {|s| p s} NoMethodError: undefined method `each' for "hello\nworld":String ...but I get…
Tom
  • 231
  • 1
  • 2
  • 3
23
votes
16 answers

Really cool features in Ruby 1.9

With the Ruby 1.9.2 release on the horizon, it's time to get developers excited about Ruby 1.9. What are some nice things you can do in Ruby 1.9 that you can't do in Ruby 1.8?
shinzui
  • 281
  • 2
  • 7
22
votes
2 answers

Is it possible to define a block with default arguments in Ruby?

This question deals with optional arguments passed to a Ruby block. I'm wondering if it's also possible to define arguments with default values, and what the syntax for that would be. At first glance, it appears that the answer is "no": def call_it…
Craig Walker
  • 49,871
  • 54
  • 152
  • 212
22
votes
4 answers

gem install mongrel fails with ruby 1.9.1

I initiated myself into rails development yesterday. I installed ruby 1.9.1, rubygems and rails. Running gem install mongrel worked fine and ostensibly installed mongrel too. I am slightly puzzled because: script/server starts webrick by…
atlantis
  • 3,056
  • 9
  • 30
  • 41
21
votes
1 answer

Why does Ruby 1.9.2 blow up with a JSON gem dependency?

I am having issues with the JSON gem and Ruby 1.9.2. I am upgrading to Rails 3.0.3 and whenever I try to boot the environment it blows up. This is from a empty test project with only JSON gem 1.4.6 as a dependency.…
Lee
  • 9,432
  • 3
  • 30
  • 34
20
votes
3 answers

How can I choose Ruby version on Heroku?

I use Ruby 1.9.x syntax in my Rails 3 app, but after pushing it to Heroku it crashes due to older Ruby version (1.8). How can I control it?
Andrei
  • 10,918
  • 12
  • 76
  • 110
19
votes
2 answers

Why isn't the Ruby 1.9 lambda call possible without the dot in front of the parentheses ?

I checked out the latest Ruby version, to play a bit with the latest changes. The first thing I tried to do was call a Ruby lambda/block/proc just like you'd do with a Python callable. a = lambda {|x| puts x} a.call(4) # works, and prints 4 a[4] #…
Geo
  • 93,257
  • 117
  • 344
  • 520
19
votes
1 answer

What are tainted objects, and when should we untaint them?

When do Ruby objects need to be made tainted and when should we untaint them? How does the concept of tainted object make a Ruby script run in safe mode? Can anyone elaborate on this to make the concept clear with some code snippets?
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
1
2
3
28 29