Class: SqueezeDrill

Inherits:
Drill
  • Object
show all
Defined in:
lib/ruby_drills/string/squeeze_drill.rb

Constant Summary

Constants included from Commands

Commands::GAMBLER

Instance Attribute Summary

Attributes inherited from Drill

#hints, #next, #previous

Instance Method Summary collapse

Methods inherited from Drill

#done?, #drills, #expected, #initialize, #non!

Methods included from Commands

#back, #clear, #continue, #fail, #fold, #help, #hint, #quit, #review, #skip, #welcome, #win

Constructor Details

This class inherits a constructor from Drill

Instance Method Details

#referenceObject



19
20
21
# File 'lib/ruby_drills/string/squeeze_drill.rb', line 19

def reference
  "@value.squeeze"
end

#setupObject



3
4
5
6
7
# File 'lib/ruby_drills/string/squeeze_drill.rb', line 3

def setup
  @value = %{Mississippi}
  @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

#showObject



9
10
11
12
13
14
15
16
17
# File 'lib/ruby_drills/string/squeeze_drill.rb', line 9

def show
  puts %{
@value = #{@value.inspect}

Remove all of the repeating characters from Mississippi,
leaving only one instance of each, to product #{expected.inspect}.

}
end

#valid?(input) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ruby_drills/string/squeeze_drill.rb', line 23

def valid?(input)
  non!("squeeze", input)
end