module Kernel

Public Instance Methods

allocate(ratios) click to toggle source
# File lib/guerrilla_patch/kernel.rb, line 114
def allocate(ratios)
  Allocate.new(self.to_d, ratios).divided
end
allocate_evenly(number_of_slices) click to toggle source
# File lib/guerrilla_patch/kernel.rb, line 110
def allocate_evenly(number_of_slices)
  Allocate.evenly(self.to_d, number_of_slices)
end
auto_assign(caller_binding) click to toggle source
# File lib/guerrilla_patch/kernel.rb, line 5
def auto_assign(caller_binding)
  method(caller[0][/`.*'/][1..-2]).parameters.each { |arg| instance_eval("@#{arg[1]} = caller_binding.eval(arg[1].to_s)") }
end
consists_of() { |builder| ... } click to toggle source
# File lib/guerrilla_patch/kernel.rb, line 25
def consists_of
  PoorsManStringBuilder.new.tap { |builder| yield(builder) }.result
end
let(name, &block) click to toggle source
# File lib/guerrilla_patch/kernel.rb, line 9
def let(name, &block)
  define_method(name, &block)
end
let_self(name, &block) click to toggle source
# File lib/guerrilla_patch/kernel.rb, line 13
def let_self(name, &block)
  define_singleton_method(name, &block)
end
plural(item) click to toggle source
# File lib/guerrilla_patch/string.rb, line 37
def plural(item) item.count > 1 ? 's' : '' end
to_d() click to toggle source
# File lib/guerrilla_patch/kernel.rb, line 106
def to_d
  BigDecimal.new(self.to_s)
end
when_present(item, &block) click to toggle source
# File lib/guerrilla_patch/kernel.rb, line 17
def when_present(item, &block)
  if block_given?
    item.nil? ? '' : block.call(item)
  else
    item
  end
end