Code Monkey home page Code Monkey logo

learn_ruby's People

Contributors

alexch avatar nchaffee avatar ruggeri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn_ruby's Issues

Issues with "require" in ruby 1.9.3

I have Ruby 1.9.3 installed. When I tried doing the exercises, I kept getting this error:

/Users/stevenjli/Documents/App Academy/learn_ruby-master/00_hello/hello_spec.rb:116:in `require': cannot load such file

I asked around StackExchange, where the posters suggested that "require" might be the issue. Namely, because I'm using Ruby 1.9.3, the "require" needs to be changed to "require_relative." They were right. I went through every spec.rb file and changed "require" to "require_relative" and this got things working.

Rake Error

Good Evening,

I have been unable to run the tests and I have no clue what is wrong. I am encountering an issue in the terminal after running the 'rake' command per the instructions in the index.html file. This is the message that I receive, any suggestions or advice would be greatly appreciated. Thank you.

$ rake
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in eval' /usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in

'
(See full trace by running task with --trace)

$ rake --trace
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.0/lib/rake/application.rb:632:in raw_load_rakefile' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.0/lib/rake/application.rb:94:inblock in load_rakefile'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.0/lib/rake/application.rb:165:in standard_exception_handling' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.0/lib/rake/application.rb:93:inload_rakefile'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.0/lib/rake/application.rb:77:in block in run' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.0/lib/rake/application.rb:165:instandard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.0/lib/rake/application.rb:75:in run' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.0/bin/rake:33:in<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p392/bin/rake:19:in load' /usr/local/rvm/gems/ruby-1.9.3-p392/bin/rake:19:in

'
/usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in eval' /usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in'

Trouble with exercise 11: Dictionary

hello,

While working on the dictionary exercise, I was running into some problems. For a check, I decided to run your solution, but your solution was failing the 2nd test. Do I need some special installation to run "Dictionary" that is different from the previous exercises?

Thanks

require vs. require_relative - hello exercise

https://github.com/alexch/learn_ruby/tree/master/00_hello

This is for everyone's benefit:

I think this is partially because I'm running Ruby 2.0.0, not 1.8.7

When I try "rspec hello_spec.rb" from the Terminal, I get that it can't load the "hello" file, with a listing of directories that it tried to load it from.

I did not define those directories, nor do I know if I can change them.

However, a little research shows me that I can use the "require_relative" method instead of simply "require." Then, if I put "hello.rb" in the same folder as "hello_spec.rb", I can run the test and everything works out.

That took me an hour, so I hope this post saves somebody some time!

  • ianalexh

Problem with Exercise 12 RPNCalculator test

"resolves operator precedence unambiguously" test tries doing two consecutive calculations without resetting the calculator. Basically, it is testing whether:
2+3_((1 + 2) * 3)==1+(2_3)

A fix would to be to require a method that resets the calculator and use that between the tests, or create a new instance of RPNCalculator before the test.

Relevant Code in rpn_calculator_spec.rb:

it "resolves operator precedence unambiguously" do
    #1 2 + 3 * => (1 + 2) * 3
    calculator.push(1)
    calculator.push(2)
    calculator.plus
    calculator.push(3)
    calculator.times
    calculator.value.should == (1+2)*3

    ####
    #Tom Conrad: Error here.  Calculator has
    #to be reset.
    ####

    #1 2 3 * + => 1 + (2 * 3)
    calculator.push(1)
    calculator.push(2)
    calculator.push(3)
    calculator.times
    calculator.plus
    calculator.value.should == 1+(2*3)
  end

rake -> NoMethod error: undefined method 'last comment'...

The solution is found here: http://stackoverflow.com/questions/35893584/nomethoderror-undefined-method-last-comment-after-upgrading-to-rake-11

Here are very detailed directions in the case that more information is needed or the link doesn't work:
1] Go to the project's folder and open Gemfile (not lock) in your text editor
2] Comment out (Add a # before the text) or delete the line stating gem rake
3] Add the line gem 'rake', '< 11.0'
4] Open your terminal or command line with the current directory being inside the project's folder
5] Run bundle install
6] Run grep rake Gemfile.lock

Now when you cd into a specific excercise and run rake, it should work (you'll receive output from a failed test)

Tutorial does not work with rspec3

Using rspec 3 causes the first run of rake to fail as it's unable to find the required rspec version (~2).

See also (first answere here)[https://stackoverflow.com/questions/25107583/rake-aborted-gemloaderror-could-not-find-rspec-x-but-did-find-y].

Pig Latin - End of My Rope! - [\"a\"]

https://github.com/alexch/learn_ruby/tree/master/04_pig_latin

All right, 6-8 hours over 3 days on this one.... could use a clue...

I feel I'm very close. The idea is to split the string into words, and then split the words into letters. Find the first vowel in each letter array - with a special case if inculde?("q")

repl.it appears to give me the correct return, but rspec does not.

Example from rspec:
expected: "appleay"
got: "["a", "p", "p", "l", "e"][]ay" (using ==)

Any easy way to turn "a", "p"\ into "ap"? array.join and array.flatten don't do it.

My code - which I'm pretty proud of after all this time:


def translate(string)
string.downcase!
split_array = string.split(" ")
split_array_final_composite = []
split_array_letter_end = []

split_array.each do |word|
if word.include?("q")
#here I'm trying to get an index for the first vowel. Has to be a better way, but it works!
string_copy = word.clone
string_copy[/[aeio]/] = ''
string_index = string_copy.index("
")
split_array_letter = word.split("")
split_array_letter_end = split_array_letter.shift(string_index)
split_array_final_composite<<"#{split_array_letter}#{split_array_letter_end}ay"

else
  #here I'm trying to get an index for the first vowel. Has to be a better way, but it works!
  string_copy = word.clone
  string_copy[/[aeiou]/] = '*'
  string_index = string_copy.index("*")
  split_array_letter = word.split("")
  split_array_letter_end = split_array_letter.shift(string_index)
  split_array_final_composite<<"#{split_array_letter}#{split_array_letter_end}ay"
end

end

split_array_final_composite.flatten #this is un-necessary
return split_array_final_composite.join(" ")
end

translate("the quick red fox jumps over the lazy dog")

repl.it returns:
=> "ethay ickquay edray oxfay umpsjay overay ethay azylay ogday"

** It just now occurs to me that perhaps I don't have to split into letters any more, since now I've found a different way to find that vowel index, which was the original purpose of splitting into letters..... I'll try again without that step and see what happens.....
** No, that's right, I did need to split into letters because "shift" works for entire array elements, not for each contstituent part of the element.... still stumped....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.