ruby-1.9 Questions
5
Solved
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...
8
I'm getting some string data from the web, and I suspect that it's not always what it says it is. I don't know where the problem is, and I just don't care any more. From day one on this project I'v...
8
Solved
I want find the length of a Fixnum, num, without converting it into a String.
In other words, how many digits are in num without calling the .to_s() method:
num.to_s.length
4
Solved
3
Solved
Ruby 1.9 version of csv
header %w[first second third]
data = ["column one",,"column three"]
CSV.open("myfile.csv","w") do |csv|
csv << header
csv << data
end
In this simple examp...
8
Solved
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,...
5
Solved
I want to use grep with a string as regex pattern. How can i do that?
Example:
myArray.grep(/asd/i) #Works perfectly.
But i want to prepare my statement first
searchString = '/asd/i'
myArray.g...
3
I am upgrading my app to Rails 3.2 on Ruby 1.9. I had to drop attachment_fu. Carrierwave seemed the obvious replacement. At this stage I am uploading files to the file system (no cloud files, yet)....
Ology asked 30/5, 2012 at 5:17
4
Solved
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//IGNO...
Peonage asked 3/1, 2012 at 9:57
11
What is the best practice if I want to require a relative file in Ruby and I want it to work in both 1.8.x and >=1.9.2?
I see a few options:
just do $LOAD_PATH << '.' and forget everything...
4
Solved
In ruby 1.9 is there a way to define this hash with the new syntax?
irb> { a: 2 }
=> {:a=>2}
irb> { a-b: 2 }
SyntaxError: (irb):5: syntax error, unexpected tLABEL
{ a-b: 2 }
^
with...
4
Solved
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 ...
2
Recent versions of Ruby support the use of braces in globbing, if you use the File::FNM_EXTGLOB option
From the 2.2.0 documentation
File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> tru...
6
I'm trying to generate a list of all routes generated by my subclass of Grape::API (MyApi).
I can get close by calling:
MyApi.send(:route_set).instance_variable_get(:@routes)
which gives me an ...
Vd asked 11/6, 2011 at 19:34
5
Solved
Is there any difference between :key => "value" (hashrocket) and key: "value" (Ruby 1.9) notations?
If not, then I would like to use key: "value" notation. Is there a gem that helps me to conve...
Powder asked 30/12, 2011 at 1:9
3
Solved
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?
Sepulchral asked 31/8, 2010 at 23:29
5
Solved
I found a similar post here but I can't solve the problem anyway.
I got this
/home/fra/siti/Pensiero/db/seeds.rb:32: invalid multibyte char (US-ASCII)
/home/fra/siti/Pensiero/db/seeds.rb:32: invali...
Impassion asked 12/10, 2010 at 16:32
2
Solved
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 "com...
Bushweller asked 23/11, 2011 at 23:16
7
Solved
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,...
Repulsion asked 29/11, 2011 at 22:49
4
Solved
In python, it's fairly straightforward to reference a function:
>>> def foo():
... print "foo called"
... return 1
...
>>> x = foo
>>> foo()
foo called
1
>>> x...
Sideways asked 27/11, 2010 at 23:27
3
Solved
I want to tell ruby that everything is utf8, except when stated otherwise, so I dont have to place these # encoding: utf-8 comments everywhere.
5
Solved
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 re...
Nyssa asked 20/8, 2009 at 16:34
7
Solved
I'm in the U.S., and we usually format dates as "month/day/year". I'm trying to make sure that my Rails app, using Ruby 1.9, assumes this format everywhere, and works the way it did under...
Centralism asked 2/9, 2011 at 16:26
6
I'm using Ruby 1.9.1 with Rails 2.3.4 My application is to handle text input
If I try something like (the inside quotation marks look different)
text = "”“"
I get the following error:
#<Syn...
Gnaw asked 16/11, 2009 at 3:0
4
Solved
I'm not clear on the differences between the "current" version of Ruby (1.8) and the "new" version (1.9). Is there an "easy" or a "simple" explanation of the differences and why it is so different?...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.