This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
EasyVR Tester | |
Dump contents of attached EasyVR module | |
and exercise it with playback and recognition. | |
Serial monitor can be used to send a few basic commands: | |
'c' - cycles through available command groups | |
'b' - cycles through built-in word sets | |
's123.' - play back sound 123 if available (or beep) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LabeledString < String | |
end | |
s1 = LabeledString.new("Secret Name") | |
/n(a)(m)e/i =~ s1 | |
p [$1, $1.class, LabeledString] | |
p [$2, $2.class, LabeledString] | |
p [$`, $`.class, LabeledString] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RegexpSub < Regexp | |
def match *args | |
"regexp_match" | |
end | |
end | |
reg = RegexpSub.new("he") | |
p "hello".match(reg) == "regexp_match" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pwh-argon:rubinius pwh$ rvm use ruby | |
Using /Users/pwh/.rvm/gems/ruby-2.0.0-p247 | |
pwh-argon:rubinius pwh$ bin/mspec -tr core/string/match_spec.rb | |
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0] | |
...................... | |
Finished in 0.003534 seconds | |
1 file, 22 examples, 37 expectations, 0 failures, 0 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LabeledString < String | |
def +(other) | |
LabeledString.new original_plus(other) | |
end | |
end | |
class String | |
alias_method :original_plus, :+ | |
def +(other) |
NewerOlder