Module: Behold

Defined in:
lib/behold.rb,
lib/behold/version.rb,
lib/behold/arity_range.rb

Defined Under Namespace

Modules: ArityRange

Constant Summary collapse

FORBIDDEN =
%i[__binding__ byebug debugger instance_eval pry
public_send __send__ send].freeze
EMPTY_FUZZ =
[nil].freeze
FUZZ =
[*0..10,
-1.0, 0.0, 1.0,
[], {},
Float::INFINITY, Float::NAN,
'', *' '..'~', '  ', ', ', "\n", "\t", "\r",
'lowercase words', 'Capitalized Words', 'UPPERCASE WORDS',
//, /.+/, /\h+/,
:to_s, :to_i, :to_h, :to_a,
:join, :<<, :+, :-, :*, :inject, :new,
nil, true, false,
nil..nil, 1..10, 'a'..'f',
Time.now, Object, Module, Kernel,
*-10..-1, *11..101, *-101..11, 1_000, 10_000, -1_000, -10_000].freeze
DOUBLE_FUZZ =
FUZZ.repeated_combination(2).to_a.freeze
FUZZES =
[EMPTY_FUZZ, FUZZ, DOUBLE_FUZZ].freeze
RESULT_COUNT =
6
DEFAULT_TIMEOUT =
3
MAJOR_VERSION =
0
MINOR_VERSION =
0
TEENY_VERSION =
0
VERSION =
"#{MAJOR_VERSION}.#{MINOR_VERSION}.#{TEENY_VERSION}"

Class Method Summary collapse

Class Method Details

.call(from, to) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/behold.rb', line 39

def call(from, to)
  black_hole do
    lazy_tries = FUZZES.map.with_index do |fuzz, index|
      match(from: from, to: to, fuzz: fuzz, arg_count: index)
    end

    best_matches(lazy_tries)
  end
end

.code(from, to) ⇒ Object



33
34
35
36
37
# File 'lib/behold.rb', line 33

def code(from, to)
  call(from, to).map do |meth, *args|
    "#{from.inspect}.#{meth}#{"(#{args.map(&:inspect).join ', '})" unless args.empty?}"
  end
end