Sha256: d18a1f11f4a3283f87adb65902b3aa9784065b0ee914e65680a4d6942328db3a

Contents?: true

Size: 1.45 KB

Versions: 1221

Compression:

Stored size: 1.45 KB

Contents

require 'method_source'
require 'rspec'

def is_rbx?
  defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
end

def jruby?
  defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
end


# This is a comment for module
module M
  def hello; :hello_module; end
end

# This is a comment for class
class C
  include M
end

$o = Object.new
def $o.hello; :hello_singleton; end

# A comment for hello

  # It spans two lines and is indented by 2 spaces
def hello; :hello; end

# a
# b
def comment_test1; end

 # a
 # b
def comment_test2; end

# a
#
# b
def comment_test3; end

# a

# b
def comment_test4; end


# a
  # b
    # c
# d
def comment_test5; end

# This is a comment for MyLambda
MyLambda = lambda { :lambda }
MyProc = Proc.new { :proc }


name = "name"

M.instance_eval <<-METHOD, __FILE__, __LINE__ + 1
  def hello_#{name}(*args)
    send_mesg(:#{name}, *args)
  end
METHOD

M.class_eval <<-METHOD, __FILE__, __LINE__ + 1
  def hello_#{name}(*args)
    send_mesg(:#{name}, *args)
  end
METHOD

# module_eval to DRY code up
#
M.module_eval <<-METHOD, __FILE__, __LINE__ + 1

  # module_eval is used here
  #
  def hi_#{name}
    @var = #{name}
  end
METHOD

# case where 2 methods are defined inside an _eval block
#
M.instance_eval <<EOF, __FILE__, __LINE__ + 1

  def #{name}_one()
    if 40 + 3
      44
    end
  end


  def #{name}_two()
    if 40 + 4
      45
    end
  end
EOF

# class_eval without filename and lineno + 1 parameter

M.class_eval "def #{name}_three; @tempfile.#{name}; end"

Version data entries

1,221 entries across 1,221 versions & 11 rubygems

Version Path
cybrid_api_id_ruby-0.115.104 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_bank_ruby-0.115.102 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_id_ruby-0.115.102 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_organization_ruby-0.115.102 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_organization_ruby-0.115.101 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_bank_ruby-0.115.101 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_id_ruby-0.115.101 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_organization_ruby-0.115.100 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_id_ruby-0.115.100 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_bank_ruby-0.115.99 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_id_ruby-0.115.99 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_organization_ruby-0.115.99 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_organization_ruby-0.115.98 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_id_ruby-0.115.98 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_organization_ruby-0.115.97 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_id_ruby-0.115.97 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_bank_ruby-0.115.97 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_organization_ruby-0.115.96 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_id_ruby-0.115.95 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb
cybrid_api_organization_ruby-0.115.95 vendor/bundle/ruby/3.2.0/gems/method_source-1.1.0/spec/spec_helper.rb