Sha256: 087fdcb0ec41c44bd7df70040b468bd143384ad45ba8f33b19991546814bd957

Contents?: true

Size: 618 Bytes

Versions: 86

Compression:

Stored size: 618 Bytes

Contents

# encoding: utf-8

module EvalHelper
  # create each with index brace single line code, for eval
  #
  # ==== Examples
  #
  #   class EvalHelperEachWithIndexBraceTest
  #     include EvalHelper
  #
  #     def hoge(hash)
  #       each_with_index_brace_code(hash[:target], hash[:proc])
  #     end
  #   end
  #
  #   hash = {
  #     target: '[:a, :b]',
  #     proc: 'puts "#{i}:#{v}"',
  #   }
  #   EvalHelperEachWithIndexBraceTest.new.hoge(hash) # => return '[:a, :b].each { |v, i|puts "#{i}:#{v}" }'
  #
  def each_with_index_brace_code(target, proc)
    "#{target}.each_with_index { |v, i|#{proc} }"
  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.150 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.149 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.148 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.147 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.146 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.145 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.144 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.143 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.142 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.141 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.140 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.139 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.138 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.137 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.136 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.135 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.134 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.133 lib/eval_helper/each_with_index_brace_code.rb
tbpgr_utils-0.0.132 lib/eval_helper/each_with_index_brace_code.rb