find selectors in ruby by example. Ex: "hello" -> "HELLO" finds 'upcase' method
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README
method_finder.rb
method_finder_spec.rb

README

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