Sha256: 0dd38a5b231ca3ea35e2c4e71e57d60ae29a843ba87da986a98e21e899ce7187
Contents?: true
Size: 511 Bytes
Versions: 5
Compression:
Stored size: 511 Bytes
Contents
# encoding: utf-8 class Object def try(*a, &b) if a.empty? && block_given? yield self else public_send(*a, &b) if respond_to?(a.first) end end def try!(*a, &b) if a.empty? && block_given? yield self else public_send(*a, &b) end end end class NilClass def try(*args) nil end def try!(*args) nil end end class String def strip_heredoc indent = scan(/^[ \t]*(?=\S)/).min.try(:size) || 0 gsub(/^[ \t]{#{indent}}/, '') end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
daiku-0.2.2 | lib/daiku/core_ext.rb |
daiku-0.2.1 | lib/daiku/core_ext.rb |
daiku-0.2.0 | lib/daiku/core_ext.rb |
daiku-0.1.1 | lib/daiku/core_ext.rb |
daiku-0.1.0 | lib/daiku/core_ext.rb |