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
19
votes
1 answer

How do I write the hour of the time without a leading zero or leading space?

In a Ruby 1.9 program, I want to format the current time like Thu 1:51 PM. What format code should I use for the hour of the day (1 in this example)? Time.now.strftime '%a %I:%M %p' #=> "Thu 01:51 PM" Time.now.strftime '%a %l:%M %p' #=> "Thu 1:51…
Rory O'Kane
  • 29,210
  • 11
  • 96
  • 131
18
votes
7 answers

Not assigning nil values to a hash

Is there a short hand or best practice for assigning things to a hash when they are nil in ruby? For example, my problem is that I am using another hash to build this and if something in it is nil, it assigns nil to that key, rather than just…
Red
  • 2,256
  • 5
  • 25
  • 38
18
votes
1 answer

write csv in ruby 1.9 and CSV::Writer

i have a code that works fine with ruby 1.87 but dont works with ruby 1.9. It says that CSV::Writer is undeclared but it still part of the rdoc. Does the csv api changed, after the fastercsv merge, or not? my code: require 'csv' def…
VP.
  • 5,122
  • 6
  • 46
  • 71
17
votes
4 answers

Why Ruby 1.9 GUI hangs if i do any intensive computation in separate Ruby thread?

Ruby 1.9 is supposed to have native threads, and GIL is supposed to lift if some threads enters native code (like GUI toolkit main loop or C implementation of some Ruby lib). But if i start following simple code sample that displays GUI in main…
grigoryvp
  • 40,413
  • 64
  • 174
  • 277
17
votes
4 answers

Can I set the default string encoding on Ruby 1.9?

This might sound minor, but it's been driving me nuts. Since releasing an application to production last Friday on Ruby 1.9, I've been having lots of minor exceptions related to character encodings. Almost all of it is some variation…
SFEley
  • 7,660
  • 5
  • 28
  • 31
17
votes
2 answers

Rubinus or MRI 1.9.3 (YARV)?

So, I have a few questions that I have to ask, I did browse the internet, but there weren't too many reliable answers. Mostly blog posts that would cancel each-other out because they both praised different things and had benchmarks to "prove their…
omninonsense
  • 6,644
  • 9
  • 45
  • 66
16
votes
1 answer

Disabling echo from webrick

How can I disable messages from webrick echoed on to the terminal? For the INFO messages that appear at the beginning, I was able to disable it by setting the Logger parameter so as: s = WEBrick::HTTPServer.new( Port: 3000, BindAddress:…
sawa
  • 165,429
  • 45
  • 277
  • 381
16
votes
2 answers

Ruby 1.9 Array.to_s behaves differently?

i wrote a quick little application that takes a base file of code with some keywords, a file of replacements for the keywords, and outputs a new file with the keywords replaced. When i was using Ruby 1.8, my outputs would look fine. Now when using…
jrsconfitto
  • 1,134
  • 1
  • 11
  • 33
16
votes
2 answers

Implicit argument passing of super from method defined by define_method() is not supported

In "Agile Web Development with Rails" (third edition) page 537 - 541 it has "Custom Form Builders" code as follows: class TaggedBuilder < ActionView::Helpers::FormBuilder #

#
# <%=…

jaycode
  • 2,926
  • 5
  • 35
  • 71
16
votes
4 answers

require lib in RSpec with Ruby 1.9.2 brings "no such file to load"

I am trying to upgrade one of my Rails projects to Ruby 1.9.2. All went pretty well, but one RSpec test broke. In this test I require a Ruby lib: # file spec/models/my_lib_spec.rb require 'spec_helper' require 'lib/services/my_lib' describe "MyLib"…
DiegoFrings
  • 3,043
  • 3
  • 26
  • 30
15
votes
1 answer

syntax error, unexpected ',', expecting ')'

I just installed Ruby 1.9.2 after having used 1.8.7, as there is a feature I need. I had called many of my methods like this: do_something (arg0, arg1) With 1.9.2, i get the following error, syntax error, unexpected ',', expecting ')' and the fix…
dt1000
  • 3,684
  • 6
  • 43
  • 65
15
votes
2 answers

Are there any good mutation testing tools for ruby 1.9 and RSpec2?

I used to use Heckle, but it is incompatible with ruby 1.9 because of issues with ParseTree. I've looked for alternatives, but the only thing that looked promising was Chaser, and that did not have any clear documentation that I could use to see if…
Matt Van Horn
  • 1,654
  • 1
  • 11
  • 21
15
votes
2 answers

How to check a String if it's an ASCII or not?

For example something like: "ASCII".is_ascii? # => true "تجربة".is_ascii? # => false
Amer
  • 1,968
  • 4
  • 21
  • 25
15
votes
3 answers

Is autoload thread-safe in Ruby 1.9?

It seems to me that the Ruby community has been freaking out a little about autoload since this famous thread, discouraging its use for thread safety reasons. Does anyone know if this is no longer an issue in Ruby 1.9.1 or 1.9.2? I've seen a bit of…
SFEley
  • 7,660
  • 5
  • 28
  • 31
14
votes
4 answers

Is there a Regex Delete in Ruby?

All of my string delete's with regex use gsub, is there a shorter way? string.gsub(/\A.*\//,'')
Mr. Demetrius Michael
  • 2,326
  • 5
  • 28
  • 40
1 2
3
28 29