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

Does Time.to_i always return number of seconds since EPOCH in UTC?

Is the timezone difference always ignored, regardless in which zone the time is expressed in? Intuitively, the number of seconds passed since EPOCH should be higher for those who are, for example, in UTC+2. However, this seems not to be the case.
randomguy
  • 12,042
  • 16
  • 71
  • 101
7
votes
1 answer

Functional unwrapping of nested array

Given an array containing other nested arrays, I want to create an array containing only the elements from the first array. For example [["1", "2"], "3", [["4"]]] should evaluate to ["1", "2", "3", "4"]. I've managed to make a method that…
Prisen
  • 73
  • 3
7
votes
4 answers

How to use ruby fibers to avoid blocking IO

I need to upload a bunch of files in a directory to S3. Since more than 90% of the time required to upload is spent waiting for the http request to finish, I want to execute several of them at once somehow. Can Fibers help me with this at all? They…
Sean Clark Hess
  • 15,859
  • 12
  • 52
  • 100
7
votes
2 answers

incompatible character encodings: ASCII-8BIT and UTF-8 in Ruby 1.9

I'm getting the following error with my Ruby 1.9 & Rails 2.3.4. This happens when user submits a non-ASCII standard character. I read a lot of online resources but none seems to have a solution that worked. I tried using (as some resources…
Tam
  • 11,872
  • 19
  • 69
  • 119
7
votes
1 answer

Paper Clip failing to save attachment

I'm using Ruby 1.9 and Rails 2.3.4 with Paperclip gem to save attachments. and I followed tutorial by adding the proper migration, adding (has_attached_file :video) to the model, making the form (multipart) and adding <%= f.file_field :video %> to…
Tam
  • 11,872
  • 19
  • 69
  • 119
7
votes
1 answer

Why this code is not compiling on ruby 1.9 but is on ruby 1.8?

Sorry for the title, I don't know how this syntax is called. For instance: ary = [ [11, [1]], [22, [2, 2]], [33, [3, 3, 3]] ] # want to get [ [11, 1], [22, 2], [33, 3] ] Ruby 1.8 ary.map{|x, (y,)| [x, y] } #=> [[11, 1], [22, 2], [33,…
oldergod
  • 15,033
  • 7
  • 62
  • 88
6
votes
4 answers

Why can procs be invoked with === in ruby 1.9?

This article mentions 4 ways to invoke procs in ruby 1.9, and === is one of them. I don't understand why this would be done this way at all. Does it have any relationship to the normal meaning of === (asking if the two objects are the same…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
6
votes
1 answer

ruby serialport gem, who is responsible to check parity errors?

gems serialport (1.0.4) Authors: Guillaume Pierronnet, Alan Stern, Daniel E. Shipton, Tobin Richard, Hector Parra, Ryan C. Payne Homepage: http://github.com/hparra/ruby-serialport/ Library for using RS-232 serial ports. I am using this gem, and my…
kukrt
  • 2,117
  • 3
  • 21
  • 32
6
votes
1 answer

How do I convert a Block to a Proc in a Ruby 1.9 C extension?

I'm writing a Ruby 1.9 C extension and I want to do the following in ruby: notifier = Notifier.new notifier.on 'click' do puts "clicked!" end Now the problem with this is that on the C method, I only "receive" a block, and, as far as I know, it's…
rubenfonseca
  • 699
  • 10
  • 26
6
votes
1 answer

Sinatra app with sprockets not working on Heroku

I have a little Sinatra app including this module: module Sprockets module Helpers def asset_path(source) "/assets/#{Environment.instance.find_asset(source).digest_path}" end def sprockets Environment.instance.call(env) …
Mario Uher
  • 12,249
  • 4
  • 42
  • 68
6
votes
2 answers

What aynchronous Ruby server to use?

We're starting development of the new game project using Ruby. We decided to use one of the asynchronous Ruby servers, but we cannot decide which one to choose. Options are: Goliath Cramp + thin/rainbows rack-fiber_pool + rack +…
6
votes
2 answers

Unable to install rmagick, ruby 1.9, rails 3, windows

I've been googling for a while but couldn't find anything that works. Basically, when I put gem 'rmagick' in my gemfile and run bundle install, I get the following error message: Installing rmagick (2.13.1) with native extensions…
Max
  • 81
  • 1
  • 4
6
votes
0 answers

Converting Proc and Method to String

Possible Duplicate: How to extract the code from a Proc object? What is the best way to turn a proc or method object into its source string? So far, I have tried two approaches. One is to achieve the source location of the proc and read that part…
sawa
  • 165,429
  • 45
  • 277
  • 381
6
votes
1 answer

commenting restriction

In ruby 1.9, conditions on where to end a line was relaxed, so that we can now start a line with a period showing a method call. This is convenient when we have chained and non-chained methods mixed up, and want to show where the next non-chained…
sawa
  • 165,429
  • 45
  • 277
  • 381
6
votes
2 answers

Stopping a Distributed Ruby Service

I have a script that starts up a DRb service, before spawning a handler object and waiting via DRb.thread.join. I would like the script to run until explicitly killed, so I added trap "INT" do DRb.stop_service end which successfully stops the…
kfb
  • 6,252
  • 6
  • 40
  • 51