No commit activity in last 3 years
No release in over 3 years
when interpolating string with hash that includes lamda,you can pass interpolator object upon which the lambda is called before interpolating
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 1.3
>= 0
 Project Readme

Build Status Code Climate

Extended interpolation for ruby string

When interpolating string with hash that includes lambda, you can pass interpolator object upon which the lambda is called before interpolating the hash.

require 'ostruct'
user = OpenStruct.new(email_count: 20)

hello_string = 'hi %{user}, you have %{email_count} emails'

hello_string.class # => String
hello_string % { user: 'Joe', email_count: lambda { |user| user.email_count} }
# =>  "hi Joe, you have #<Proc:0x000000022a7928@(irb):9 (lambda)> emails"

# using this gem
extended_hello = hello_string.extended 
extended_hello.class # => ExtendedInterpolationString
extended_hello.interpolator = user
extended_hello % { user: 'Joe', email_count: lambda { |user| user.email_count} }
#  "hi Joe, you have 20 emails"

Installation

Add this line to your application's Gemfile:

gem 'extended_interpolation_string'

And then execute:

$ bundle

Or install it yourself as:

$ gem install extended_interpolation_string

Contributing

  1. Fork it ( https://github.com/[my-github-username]/extended_interpolation_string/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request