Ruby General
Find all the available instance methods for a given class
03/07/16 Public, Ruby General
To see all the instance methods available on a given class
1 - from a class object call .instance_methods on the class (i.e. User.instance_methods
)
or
2 - from ...
1 vote - harrylevine
Ruby Case statement (aka Switch statement)
11/20/15 Public, Ruby General
print "Enter your grade: "
grade = gets.chomp
case grade
when "A"
puts 'Well done!'
when "B"
puts 'Try harder!'
when "C"
puts 'You need help!!!'
else
puts "You just making it up!"
end
1 vote - harrylevine
10/09/15 Public, Ruby General
First, let's define a couple of terms: caller and mutated.
The caller is what tap
is being called on. In the below, the caller is arr
:
arr = [2, 3, 1]
arr.tap do |x|
x.sort
end
Mutated permanently change...
1 vote - harrylevine
String interpolation with single and double quotes dealing with escape characters
08/14/15 Public, Testing / TDD, Ruby General
This expectation does not recognize/interpolate the @volunteer.phone_number
:
expect(response.body).to include('<Message to="#{@volunteer.phone_number}">Anybody home?</Message>')
By using Ruby programming *alternate double quo...
1 vote - harrylevine
rbenv not showing the correct ruby version
06/19/15 Public, Ruby General
If you don't see the version of ruby in the list you need when you run rbenv install --list
run:
$ brew update && brew reinstall --HEAD ruby-build
then install the ruby version, i.e. rbenv install 2.2.1
From: https://github.com/H...
1 vote - harrylevine