mholub/method_finder
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Squeak method finder analogue by example for ruby. http://wiki.squeak.org/squeak/1916 Examples: irb(main):001:0> "hello".suggest_method("HELLO") => ["upcase", "swapcase"] irb(main):002:0> "hello".suggest_method("Hello") => "capitalize" irb(main):007:0> Date.parse('13 Sep 2009').suggest_method(256) # Programmer's Day => "yday" irb(main):009:0> 1.01.suggest_method(1) => ["prec_i", "round", "truncate", "to_i", "to_int", "floor"] irb(main):010:0> 1.01.suggest_method(2) => "ceil" MethodFinder can use several results for find method. Examples: irb(main):011:0> MethodFinder.suggest_method([-1.01, -2], [1.01, 1]) => "floor" irb(main):001:0> MethodFinder.suggest_method([-1.01, -1], [1.01, 1]) => ["to_int", "round", "to_i", "prec_i", "truncate"] Update: now with arguments irb(main):005:0> "hello ".suggest_method("hello world", "world") => ["+", "concat", "<<"] irb(main):003:0> MethodFinder.suggest_method([2, 4, 2], [[2], [2, 2], 2]) ./method_finder.rb:20: warning: do not use Fixnums as Symbols => "*" TODO: think about possible improvements
About
find selectors in ruby by example. Ex: "hello" -> "HELLO" finds 'upcase' method
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published