This file contains hidden or 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
| /home/jps/.rvm/rubies/ruby-1.9.3-p0/bin/ruby -I"lib:test/quality:lib:." -I"/home/jps/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib" "/home/jps/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/quality/test_*.rb" | |
| % cumulative self self total | |
| time seconds seconds calls ms/call ms/call name | |
| 55.46 624.54 624.54 40716 15.34 24.98 Array#include? | |
| 34.85 1016.96 392.42 43450242 0.01 0.01 Fixnum#== | |
| 1.14 1029.76 12.80 393881 0.03 0.05 Range#include? | |
| 0.94 1040.34 10.59 11030 0.96 105.86 Integer#times | |
| 0.76 1048.85 8.51 348944 0.02 0.07 Range#=== | |
| 0.70 1056.70 7.85 85317 0.09 0.48 Langusta::NGram#normalize | |
| 0.56 1063.02 6.31 86501 0.07 0.35 Langusta::UnicodeBlock.of |
This file contains hidden or 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 Deferrable < SimpleDelegator | |
| # Public: Create a side thread that wraps whatever you need to have available in the future. | |
| def initialize(&blk) | |
| super(Thread.new(&blk)) | |
| end | |
| # Internal: We need the result of the computation of this thread NOW, so block on it and return | |
| # the value. | |
| def __getobj__ |
This file contains hidden or 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
| p = lambda { |x| | |
| x * 2 | |
| } | |
| p === 7 #=> 14 |
This file contains hidden or 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
| module M | |
| def method | |
| puts "hello" | |
| end | |
| end | |
| def execute(current_module, &block) | |
| Object.new.tap do |o| | |
| o.extend(current_module) | |
| o.instance_eval &block |
This file contains hidden or 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
| module M | |
| def hello | |
| 1 | |
| end | |
| end | |
| module N | |
| include M |
This file contains hidden or 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
| ruby-1.9.3-p0 :001 > def f(x, y=1) | |
| ruby-1.9.3-p0 :002?> method(__method__).parameters | |
| ruby-1.9.3-p0 :003?> end | |
| => nil | |
| ruby-1.9.3-p0 :004 > f(1, 2) | |
| => [[:req, :x], [:opt, :y]] |
This file contains hidden or 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
| (?<ltr>[ABCEGHJKLMNPRSTVXYWZ]){0} | |
| (?<num>[0-9]){0} | |
| (?<fsa>\g<ltr>\g<num>\g<ltr>){0} | |
| (?<ldu>\g<num>\g<ltr>\g<num>){0} | |
| (?<cpc>\g<fsa> \g<ldu>){0} | |
| ^\d{5}|\g<cpc>$ |
This file contains hidden or 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
| \g<group-name> |
This file contains hidden or 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
| (?<group-name>regular-expression){0} |
This file contains hidden or 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 Basket < Struct.new(:entries) | |
| def self.new(*args) | |
| b = super(*args) | |
| b.entries ||= [] | |
| b | |
| end | |
| def total | |
| entries.inject(0.0) do |sum, entry| |