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

Version Path
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/string/format.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/string/format.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/string/format.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/string/format.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/string/format.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/powerpack-0.1.2/lib/powerpack/string/format.rb
powerpack-0.1.2 lib/powerpack/string/format.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/powerpack-0.1.1/lib/powerpack/string/format.rb
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/powerpack-0.0.9/lib/powerpack/string/format.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/powerpack-0.0.9/lib/powerpack/string/format.rb
powerpack-0.1.1 lib/powerpack/string/format.rb
powerpack-0.1.0 lib/powerpack/string/format.rb