Sha256: a7a4f76312bbbc5b9c4433e369d277c93e4ce45e0f22ad3245d8ab211713f4b5
Contents?: true
Size: 696 Bytes
Versions: 1
Compression:
Stored size: 696 Bytes
Contents
module Kernel def let(name, &block) define_method(name, &block) end def let_self(name, &block) define_singleton_method(name, &block) end def when_present(item, &block) if block_given? item.nil? ? '' : block.call(item) else item end end def consists_of PoorsManStringBuilder.new.tap { |builder| yield(builder) }.result end class PoorsManStringBuilder attr_reader :result def initialize @result = '' end def add(item) @result << item.to_s end alias :always :add def when_present(item, &block) @result << Kernel.when_present(item, &block).to_s end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
guerrilla_patch-2.1.0 | lib/guerrilla_patch/kernel.rb |