Sha256: c213811e30998472091aee65d073fd0dcba8afb4d9d44aebac68572c81201368

Contents?: true

Size: 405 Bytes

Versions: 7

Compression:

Stored size: 405 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 7 versions & 2 rubygems

Version Path
facets-2.4.0 lib/facets/string/interpolate.rb
facets-2.4.1 lib/facets/string/interpolate.rb
facets-2.4.4 lib/core/facets/string/interpolate.rb
facets-2.4.2 lib/core/facets/string/interpolate.rb
facets-2.4.3 lib/core/facets/string/interpolate.rb
facets-2.4.5 lib/core/facets/string/interpolate.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/string/interpolate.rb