Skip to content

Commit

Permalink
Fix a few typos in String drills; add a check for bang methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyno committed Jan 22, 2014
1 parent 1bdbbf4 commit 4fba655
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 39 deletions.
9 changes: 9 additions & 0 deletions lib/ruby_drills/drill.rb
Expand Up @@ -16,6 +16,15 @@ def expected
eval(reference)
end

def non!(method, input)
if (input.include?('!'))
puts "\n\tAvoid using ! methods that modify their receiver...".red
return false
end

input.include?(method)
end

def done?(input)
case input.to_sym
when :menu
Expand Down
6 changes: 3 additions & 3 deletions lib/ruby_drills/string/chomp_drill.rb
Expand Up @@ -3,7 +3,7 @@ class ChompDrill < Drill
def setup
@value = "Blueberry"
@hints = ["Would not be a very big bite, but go ahead and take one.",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-chomp"]
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-chomp"]
end

def show
Expand All @@ -12,7 +12,7 @@ def show
Make this delectable berry read as just its color!
Use the method that will remove 'berry' from the end of this string and return 'blue':
Use the method that will remove 'berry' from the end of this string and return 'Blue':
}
end

Expand All @@ -21,7 +21,7 @@ def reference
end

def valid?(input)
input.include?("chomp")
non!("chomp", input)
end

end
10 changes: 5 additions & 5 deletions lib/ruby_drills/string/delete_drill.rb
Expand Up @@ -2,8 +2,8 @@ class DeleteDrill < Drill

def setup
@value = "bobcat"
@hints = ["bob needs to be deleted, before you can let this into the house.",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-delete"]
@hints = ["bob needs to be deleted before you can let this into the house...",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-delete"]
end

def show
Expand All @@ -12,7 +12,7 @@ def show
Remove 'bob' from this string in order to return a much tamer version.
Use a non destructive method to remove 'bob' from this string and return 'cat':
Use a non-destructive method to remove 'bob' from this string and return 'cat':
}
end

Expand All @@ -21,7 +21,7 @@ def reference
end

def valid?(input)
input.include?("delete")
non!("delete", input)
end

end
end
8 changes: 4 additions & 4 deletions lib/ruby_drills/string/gsub_drill.rb
Expand Up @@ -3,14 +3,14 @@ class GsubDrill < Drill
def setup
@values = "make?this?a?real?sentence"
@hints = ["you need to substitute all of the question marks globally",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-gsub"]
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-gsub"]
end

def show
puts %{
@values = #{@values.inspect}
Nondestructively replace all occurrences of question marks and replace them with a space.
Non-destructively replace all occurrences of question marks and replace them with a space.
}
end
Expand All @@ -20,7 +20,7 @@ def reference
end

def valid?(input)
input.include?("gsub")
non!("gsub", input)
end

end
end
12 changes: 6 additions & 6 deletions lib/ruby_drills/string/include_drill.rb
@@ -1,18 +1,18 @@
class IncludeDrill < Drill

def setup
@message = "hjwotrubjof15joe7;q;j8eldjowj234nfinskpaohello2j\ndilenudbjsinfjubfhbjisnkfnbfurbrofbdj92"
@hints = ["Another way to state that something is comprised of another thing."]
@message = "hjwotrubjof15joe7;q;j8eldjowj234nfinskpaohello2j\ndilenudbjsinfjubfhbjisnkfnbfurbrofbdj92"
@hints = ["What's another way to state that something is comprised of another thing?"]
end

def show
puts %{
@message = #{@message.inspect}
Find out if this cryptic string contains the string 'hello'.
Find out if this cryptic string contains the string 'hello'.
Use the method that will return true or false depending on if the string 'hello'
is in the given string:
Use the method that will return true or false depending on if the string 'hello'
is in @message:
}
end

Expand All @@ -24,4 +24,4 @@ def valid?(input)
input.include?("include?")
end

end
end
14 changes: 8 additions & 6 deletions lib/ruby_drills/string/partition_drill.rb
@@ -1,17 +1,19 @@
class PartitionDrill < Drill

def setup
@sentence = "Half full or half empty?"
@hints = ["use 'or' as the argument","http://www.ruby-doc.org/core-1.9.3/String.html#method-i-partition"]
@sentence = "Half full or half empty?"
@hints = ["use 'or' as the argument",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-partition"]
end

def show
puts %{
@sentence = #{@sentence.inspect}
Brake this sentence into a three member array
with 'or' being the division point.
Your output should be ['Half full ', 'or', ' half empty?']:
Break this sentence into a three-member array with a method that will use 'or'
as the substring to match against.
Your output should be ['Half full ', 'or', ' half empty?']:
}
end
Expand All @@ -24,4 +26,4 @@ def valid?(input)
input.include?("partition")
end

end
end
10 changes: 5 additions & 5 deletions lib/ruby_drills/string/split_drill.rb
Expand Up @@ -4,8 +4,8 @@ def setup
@words = %{under
the
ocean}
@hints = ["Use the '\n' char as the splitting point.",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-split"]
@hints = ["Use the '\n' char as the splitting point. You might need double quotes, though...",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-split"]
end

def show
Expand All @@ -14,7 +14,7 @@ def show
Take each line and make it the member of an array.
Use the method that will break up the string by the new line character,
Use the method that will break up the string by the new line character,
and returns an array with each line as a member:
}
end
Expand All @@ -24,6 +24,6 @@ def reference
end

def valid?(input)
input.include?("split")
non!("split", input)
end
end
end
10 changes: 4 additions & 6 deletions lib/ruby_drills/string/squeeze_drill.rb
Expand Up @@ -2,8 +2,8 @@ class SqueezeDrill < Drill

def setup
@value = %{Mississippi}
@hints = ["how do you get toothpaste out of the tube.",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-squeeze"]
@hints = ["How do you get toothpaste out of a tube?",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-squeeze"]
end

def show
Expand All @@ -12,17 +12,15 @@ def show
Remove all of the repeating characters from Mississippi,
leaving only one instance of each.
Your output should be 'Misisipi'
Your output should be 'Misisipi'
}
end



def reference
"@value.squeeze"
end

def valid?(input)
input.include?("squeeze")
non!("squeeze", input)
end
end
@@ -1,16 +1,15 @@
class TosymDrill < Drill
class ToSymDrill < Drill

def setup
@value = %{mouse}
@hints = ["Use the '\n' character as the splitting point.",
"http://www.ruby-doc.org/core-1.9.3/String.html#method-i-to_sym"]
@hints = ["http://www.ruby-doc.org/core-1.9.3/String.html#method-i-to_sym"]
end

def show
puts %{
@value = #{@value.inspect}
Take this string and turn it into a symbol. The output should be ':mouse':
Take this string and turn it into a symbol. The output should be ':mouse':
}
end

Expand Down

0 comments on commit 4fba655

Please sign in to comment.