Sha256: f3b012330020eadfcfed97799185504bfdfe733d9a1b2a304318a1bcc48bdb7e

Contents?: true

Size: 403 Bytes

Versions: 10

Compression:

Stored size: 403 Bytes

Contents

class String

  # Interpolate. Provides a means of extenally using
  # Ruby string interpolation mechinism.
  #
  #   try = "hello"
  #   str = "\#{try}!!!"
  #   String.interpolate{ str }    #=> "hello!!!"
  #
  #   NOTE: The block neccessary in order to get
  #         then binding of the caller.
  #
  # CREDIT: Trans

  def self.interpolate(&str)
    eval "%{#{str.call}}", str.binding
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/string/interpolate.rb
facets-2.8.3 lib/core/facets/string/interpolate.rb
facets-2.8.2 lib/core/facets/string/interpolate.rb
facets-2.8.1 lib/core/facets/string/interpolate.rb
facets-2.8.0 lib/core/facets/string/interpolate.rb
facets-2.7.0 lib/core/facets/string/interpolate.rb
facets-2.6.0 lib/core/facets/string/interpolate.rb
facets-2.5.1 lib/core/facets/string/interpolate.rb
facets-2.5.0 lib/core/facets/string/interpolate.rb
facets-2.5.2 lib/core/facets/string/interpolate.rb