ruby-1.9

errors in deaf Grandma - Pine - No Method

白昼怎懂夜的黑 提交于 2020-01-06 14:21:08
问题 Was completing the pine exercise for Def Grandma and thought would try and take it a little further and abstract it to remove as much duplication as possible. Hope my logic with this isn't too bizzare just tried to separate things into functions. But now if I type Bye The program exits immediately without proceeding to the exitPlan function. Any advice welcome. puts 'Say something nice to Grandma.' puts 'You may need to shout > ' speak = gets.strip counter = 0 speaks(speak) def speaks(speak)

errors in deaf Grandma - Pine - No Method

孤街醉人 提交于 2020-01-06 14:21:03
问题 Was completing the pine exercise for Def Grandma and thought would try and take it a little further and abstract it to remove as much duplication as possible. Hope my logic with this isn't too bizzare just tried to separate things into functions. But now if I type Bye The program exits immediately without proceeding to the exitPlan function. Any advice welcome. puts 'Say something nice to Grandma.' puts 'You may need to shout > ' speak = gets.strip counter = 0 speaks(speak) def speaks(speak)

Best practice for installing multiple versions of Ruby, apart from rvm?

被刻印的时光 ゝ 提交于 2020-01-03 15:34:52
问题 I've been running both Ruby 1.8.7 and Ruby 1.9 for a few weeks now. I install Ruby 1.9 with the suffix 19, so that the interpreter, rake, gem, etc. commands are "ruby19", "irb19", "rake19", "gem19", etc. The 1.8.7 equivalents have no suffix and are thus defaults. I figure that's the simplest and most transparent way to manage two versions of Ruby. I can just change the #! line of my Ruby scripts to use one version or the other. I've read about fancier solutions that involve altering symlinks

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

删除回忆录丶 提交于 2019-12-31 20:17:51
问题 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" do it "should do something" do ... The lib looks like this: # file lib/services/my_lib.rb class MyLib def self.do_something ... In Ruby 1.8.7 (REE) the test worked well: $ ruby -v ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin11.1.0], MBARI

how do you start ruby 1.9 without rubygems

牧云@^-^@ 提交于 2019-12-30 09:19:27
问题 I want my app to not be able to use any installed gems. Is there a ruby 1.9 startup parameter or way of doing this programmatically? 回答1: ruby --disable-gems is the MRI (1.9) commandline parameter. "It prevents the addition of gem installation directories to the default load path". (The Ruby Programming Language, p. 391) Edit 25-10-2012: Ruby core had the same idea as @rogerdpack in the comments and added the more verbose ruby --help parameter. Ruby revision! 回答2: Looking at the rubygems

How can I use US-style dates in Rails using Ruby 1.9?

▼魔方 西西 提交于 2019-12-30 05:59:10
问题 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 Ruby 1.8. I know that lots of people have this issue, so I'd like to create a definitive guide here. Specifically: '04/01/2011' is April 1, 2011, not Jan 4, 2011. '4/1/2011' is also April 1, 2011 - the leading zeros should not be necessary. How can I do this? Here's what I have so far. Controlling Date#to_s

How can I use US-style dates in Rails using Ruby 1.9?

别来无恙 提交于 2019-12-30 05:59:02
问题 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 Ruby 1.8. I know that lots of people have this issue, so I'd like to create a definitive guide here. Specifically: '04/01/2011' is April 1, 2011, not Jan 4, 2011. '4/1/2011' is also April 1, 2011 - the leading zeros should not be necessary. How can I do this? Here's what I have so far. Controlling Date#to_s

How can I choose Ruby version on Heroku?

岁酱吖の 提交于 2019-12-29 20:10:43
问题 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? 回答1: Heroku's current stack, Cedar, uses 1.9.2 by default. Cedar also supports specifying the Ruby version in your Gemfile. Currently, 1.9.2 and 1.9.3 are valid options. # Gemfile source "https://rubygems.org" ruby "1.9.3" ... More details are available in the Ruby support article: https://devcenter.heroku.com/articles/ruby-support If you are currently

How can I avoid putting the magic encoding comment on top of every UTF-8 file in Ruby 1.9?

血红的双手。 提交于 2019-12-29 03:26:05
问题 I have a Rails project with a lot of Cyrillic strings in it. It worked fine on Ruby 1.8, but Ruby 1.9 assumes source files are US-ASCII-encoded unless you provide an # encoding: utf-8 comment at the top of the source file. At that point the files are not considered US-ASCII . Is there a simpler way to tell Ruby "This application is UTF8-encoded. Please consider all and any included source files as UTF8 unless declared otherwise"? UPDATE: I wrote "How to insert the encoding: UTF-8 directive

ruby require not working

瘦欲@ 提交于 2019-12-25 05:21:48
问题 I'm new to ruby, but I'm working on my first ruby program. It currently has two files, one is a library of functions ( xgync.rb stored in lib ) the other is the executable xgync stored in 'bin'. (Project visible here https://bitbucket.org/jeffreycwitt/xgync/src) I've also created a symlink to my /usr/local/bin/xgync so that I can write the command xgync {arguments} from anywhere in the terminal. The problem seems to be that bin/xgync depends on the library lib/xgync.rb . I've written this