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: .

203 questions
4
votes
3 answers

Wobble Hypothesis - Combination or Permutation of Array of strings in ruby

I have a ruby array with 4 strings nucleotides = ['A', 'G', 'C', 'T'] I need 4^3 combinations of strings. new_array = ['AGC', 'AGT' .. 'TTT'] This is the wobble hypothesis in genetics. Could someone explain how I could go about achieving this…
Stacked-for-life
  • 196
  • 2
  • 17
4
votes
3 answers

Require file only if it exists

Perhaps there's a better way to do this. I want to be able to load some routes dynamically. I was planning on having static routes in routes.rb, and custom routes in custom_routes.rb. Then at the bottom of routes.rb, I would do: CustomRoutes.create…
Josh M.
  • 26,437
  • 24
  • 119
  • 200
4
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
  • 14,655
  • 24
  • 74
  • 124
4
votes
1 answer

Ruby Rails webrick server using old version of ruby

ruby -v give me ruby-1.9.3-p194. which ruby gives /home/ubuntu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby rails -v gives Rails 3.2.7 which rails gives /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/bin/rails "sudo bundle exec rails s"…
StanM
  • 827
  • 4
  • 12
  • 33
3
votes
2 answers

Hash does not contain 'try' method

I am noticing differences between a hash object within Ruby 1.8.7 and a hash object within Rails 3.0.10. For example, within the 1.8.7 irb, I get: 1.8.7 :001 > {}.try(:method) NoMethodError: undefned method `try' for {}:Hash from…
David Weiser
  • 5,190
  • 4
  • 28
  • 35
3
votes
1 answer

does memoization works inside of a proc?

I have the following method: def download_link_for(site,title=nil) template = proc {|word|(title ? "%s_#{title}_csv": "%s_csv") % word} if site.send(template.call("update")) == false x.a "Generate", :href =>…
Thermatix
  • 2,757
  • 21
  • 51
3
votes
2 answers

Equivalent of chmod +x in Ruby

In Linux, it is very easy "just" to add executable to a file, simply by input: chmod +x However, I have failed to find something as easy in the gems of Ruby. Of course, one could do a system call, i.e. system( 'chmod +x' << fname…
user1134991
  • 3,003
  • 2
  • 25
  • 35
3
votes
3 answers

Ruby Digest::SHA512.hexdigest throws a segment fault and quits in Yosemite

We have an older REE rails app that I work on my local dev environment in OSX Yosemite. I recently switched from Mavericks, with which I had no problems. I ran this app for the first time on my new work mac and found I was unable to login due to it…
3
votes
1 answer

how can you eval "local_variables" in context of a proc? in Ruby

I am using ruby 1.8.7 (2011-12-28 patchlevel 357) [i686-darwin11.2.0] I am playing with Kernet::eval method. The binding may be a Binding object or a Proc object. def eval(string, *binding_filename_lineno) end I have following test.rb require…
Usman
  • 2,325
  • 1
  • 23
  • 18
3
votes
1 answer

Ruby regexp from variable

Using Ruby 1.8.7 I want to store some regular expressions in the database and have them be easily reconstituted as a Regexp object when I need to use them for validation. I've found that Ruby exhibits some unwanted behavior. For instance: r =…
Josh M.
  • 26,437
  • 24
  • 119
  • 200
3
votes
1 answer

flat_map in Ruby 1.8.7

Using Ruby 1.8.7, is there built-in functionality similar to Array.map which allows for the return of multiple values instead of just one? E.g. I have an array and each element contains an array - I want to end up with all values from the inner…
Josh M.
  • 26,437
  • 24
  • 119
  • 200
3
votes
1 answer

Serialization/Deserialization ruby object in YAML

I'm trying to understand the serialization/deserialization of ruby object using YAML under 1.8.7 and 1.9+ and have a few queries regarding it (I can't find much documentation on this) Ruby 1.8.7 class Element yaml_as…
Ratatouille
  • 1,372
  • 5
  • 23
  • 50
3
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
  • 471
  • 4
  • 11
3
votes
1 answer

Different exponent behavior for different ruby versions

I'm trying to calculate 2^1000 in ruby, but I'm getting different results for different versions. Any idea why? Using 1.8.7: ~ » rbenv global system ~ ~ » ruby --version …
mportiz08
  • 10,206
  • 12
  • 40
  • 42
3
votes
1 answer

How to write "string".encode("us-ascii") in ruby 1.8.7?

I'm trying to use the "gmail_xoauth" gem and, unfortunately, the gem uses encode("us-ascii") for strings, which is available only for Ruby 1.9.3. I'm not familiar with encode in Ruby 1.9.3 so I wonder what is "string".encode("us-ascii") and how do…
Robert Grezan
  • 1,266
  • 3
  • 13
  • 27
1
2
3
13 14