Sha256: db54a003b6b4de52f7f2d0e43802a50326210038532ef9604ff1d8669ab40cd4

Contents?: true

Size: 389 Bytes

Versions: 7

Compression:

Stored size: 389 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

7 entries across 6 versions & 1 rubygems

Version Path
facets-2.9.3 lib/core/facets/string/interpolate.rb
facets-2.9.2 lib/core/facets/string/interpolate.rb
facets-2.9.2 src/core/facets/string/interpolate.rb
facets-2.9.1 lib/core/facets/string/interpolate.rb
facets-2.9.0 lib/core/facets/string/interpolate.rb
facets-2.9.0.pre.2 lib/core/facets/string/interpolate.rb
facets-2.9.0.pre.1 lib/core/facets/string/interpolate.rb