Sha256: 67d0ff2e462bf38419d151eb0565a42cbba16c43703611e486884f98fd4513d9

Contents?: true

Size: 898 Bytes

Versions: 94

Compression:

Stored size: 898 Bytes

Contents

# encoding: utf-8

module EvalHelper
  # create require strings, for eval
  #
  # ==== Examples
  #
  # single require case
  #
  #   class EvalHelperRequireTest
  #     include EvalHelper
  #
  #     def hoge(*args)
  #       require_code(args)
  #     end
  #   end
  #
  #   args = 'tbpgr_utils'
  #   EvalHelperRequireTest.new.hoge(args) # => return "require 'tbpgr_utils'\n"
  #
  # muiti require case
  #
  #   class EvalHelperRequireTest
  #     include EvalHelper
  #
  #     def hoge(*args)
  #       require_code(args)
  #     end
  #   end
  #
  #   args =  ['tbpgr_utils', 'eval_helper']
  #   EvalHelperRequireTest.new.hoge(args) # => return "require 'tbpgr_utils'\nrequire 'eval_helper'\n"
  #
  def require_code(*args)
    args = args.is_a?(Array) ? args.flatten : [args]
    args.reduce([]) { |ret, v|ret << "require '#{v}'\n" }.join
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.130 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.129 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.128 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.127 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.126 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.125 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.124 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.123 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.122 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.121 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.120 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.119 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.118 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.117 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.116 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.115 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.114 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.113 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.112 lib/eval_helper/require_code.rb
tbpgr_utils-0.0.111 lib/eval_helper/require_code.rb