Sha256: e0a34106bc55c9de4c2ac206387ceed98eb7142227b1f713a7e6492aa794dc05

Contents?: true

Size: 982 Bytes

Versions: 93

Compression:

Stored size: 982 Bytes

Contents

# encoding: utf-8

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

Version data entries

93 entries across 93 versions & 1 rubygems

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