Questions tagged [ruby-1.8.7]

For issues relating to developing in Ruby, version 1.8.7.

Use this specific tag along with the generic one: .

202 questions
2
votes
2 answers

Escape line breaks in puts output

In IRB on Ruby 1.8.7, I have a collection of strings I'm working with that have newlines in them. When these newlines are output, I want to explicitly see the \r and \n characters within my strings. Is there some way to tell puts to escape those…
Kevin
  • 11,714
  • 18
  • 66
  • 107
2
votes
1 answer

rbenv install is failing (telling me to install GCC, but it's already installed)

So, my client has me working on a legacy app which is running Rails 2.3.8 and Ruby 1.8.7, so I'm attempting to install the proper version of ruby using rbenv but it keeps giving me this error: → rbenv install 1.8.7-p249 ERROR: This package must be…
jarodtaylor
  • 371
  • 2
  • 11
2
votes
5 answers

Reposition an element in an Array

Say I have... arr = ["a", "b", "c"] ...and I want to move "a" between "b" and "c". I currently do arr.delete("a") arr.insert(2, "a") Can I do that in a single operation? Thanks
dublxdad
  • 143
  • 1
  • 12
2
votes
1 answer

Ruby 1.8.7: Enumerator next complains about number of arguments

When I do the following in Ruby 1.9.3 (also JRuby, Rubinius...), it works as expected: enum = [1,2,3,4,5].each #=> # enum.next #=> 1 If I try the same thing on Ruby 1.8.7 with backports, the following thing…
moonglum
  • 801
  • 5
  • 13
2
votes
1 answer

How to Convert Microsoft Office "Smart" or "Curly" Quote/Apostrophe to ASCII or UTF-8 "Straight" Quote/Apostrophe in Ruby 1.8.7?

I'm using (and stuck with) the following version of Ruby: ruby 1.8.7 (2012-06-29 patchlevel 370) [x86_64-linux] I tried a lot of Googling, but I can't find a working answer to my problem. I'm importing a CSV file that will usually come from the…
Steven Hirlston
  • 1,718
  • 1
  • 13
  • 17
2
votes
1 answer

Ruby's `File.exist?` ThreadError

I am encountering errors when I am using Ruby's File.exist? method in middleware. I have no idea why. This is the background. I am improving some old webapp which hosts around 100GB of photos and growing. I need to replicate production environment…
skalee
  • 10,976
  • 6
  • 47
  • 54
2
votes
3 answers

Can't install ruby 1.8.7 on Mac 10.8 via RVM

I can't install ruby ree or ruby 1.8.7 on my Mac 10.8.2. I did that: $ brew install libksba $ brew update $ brew install autoconf automake $ brew tap homebrew/dupes $ brew install autoconf automake apple-gcc42 Then i try to install ruby 1.8.7 and i…
ExiRe
  • 4,637
  • 6
  • 44
  • 90
2
votes
0 answers

open uri error: can't convert hash into a string

I want to get an xml content from a url (let's say http://stackoverflow.com). For this I use open uri. When I do begin status = Timeout::timeout(5) { getresult = open("http://stackoverflow.com", "UserAgent" => "Ruby-OpenURI").read } rescue =>…
Sadiksha Gautam
  • 4,604
  • 6
  • 35
  • 67
2
votes
1 answer

Unable to store UTC time in MySQL table using rails

I am able to convert a local time in string format, to UTC time format. But when i save this utc time in my MySQL table, it is getting saved in a strange format. t_utc = Time.parse('Mon Apr 23 03:00:23 -0700 2012').utc # => Mon Apr 23 10:00:23 UTC…
serpent403
  • 803
  • 14
  • 31
1
vote
3 answers

ruby regexp - how to search for one word but not if another exists (in url/uri).?

How can I do a regexp in ruby 1.8 that matches: /my_dir/1/file but not if I have: /my_dir/1/deeper_stuff/file So far I have source_string = '/my_dir/1/index.html.erb' /^\/my_dir/.match(source_string) for the initial match, how do I add the…
Michael Durrant
  • 84,444
  • 83
  • 284
  • 429
1
vote
1 answer

Ruby Openssl not being found in NET::HTTP

I'm getting the following error: /Users/user_name/.rbenv/versions/1.8.7-p375/lib/ruby/1.8/net/https.rb:124:in `use_ssl=': uninitialized constant Net::HTTP::OpenSSL (NameError) So, I opened up the https file and changed one thing just to see what…
Thermatix
  • 2,224
  • 13
  • 36
1
vote
2 answers

How to print keys and values from a text file

I have a file called "output.txt": "name": "abc", "age": 28, "name": "xxx", "age": 11, "name": "yyyb", "age": 15, I want to read the file and print the name and age values on one line, one after the other: abc 28 xxx 11 yyyb…
user1642224
  • 51
  • 11
1
vote
3 answers

Transform 2D array into hash

I have a sorted 2D array as follows: a = [[1, 2011], [3, 1999], [4, 2014], [6, 1998], ...] How can I transform this into a hash with the key being the year and the value being the number in front? {2011 => 1, 1999 => 3, 2014 => 4, 1998 => 6, ...}
Alan1
  • 83
  • 1
  • 4
1
vote
1 answer

rails-i18n translations not loading the exact data

I am using ruby 1.8.7 and i18n gem version 0.4.2 , In view page i have used

<%= " #{t('date')} :"%>

and at en.yml en: # locale net: "Net" amount_paid: "Paid Amount" date: "Date" when i executed I got this Why I am not…
Sanju B Myh
  • 271
  • 1
  • 15
1
vote
1 answer

How to count the no of rows and read the data in Excel sheet(.xlsx) in ruby using win32ole gem

I have a excel sheet(.xlsx) format which has only text data,I want to count the no of rows as well read the text data from the excel sheet in ruby using win32ole gem only.I have gone through many of the post in stackoverflow which represent these…
shaik
  • 143
  • 9