Sha256: 1362d09bc1d17459a57e6398931c4573f668afbc56ea5f22bef305db2e4bc015
Contents?: true
Size: 525 Bytes
Versions: 25
Compression:
Stored size: 525 Bytes
Contents
unless String.method_defined? :format class String # A nicer alternative to Kernel#sprintf and String#%. # # @return [String] the formatted string # # @example # 'This is %s!'.format('Sparta') #=> 'This is Sparta!' # # @example # 'My name is %{fname} %{lname}.'.format(fname: 'Bruce', lname: 'Wayne') # #=> 'My name is Bruce Wayne.' # # @example # '%d + %d'.format([1, 2]) #=> '1 + 2' def format(*args) super(self, *(args.flatten(1))) end end end
Version data entries
25 entries across 22 versions & 6 rubygems