summaryrefslogtreecommitdiff
path: root/spec/ruby/core/binding/fixtures/classes.rb
blob: 05ca2479ba5860a8d7b8e4643e1264a6db8e8656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module BindingSpecs
  class Demo
    def initialize(n)
      @secret = n
    end

    def square(n)
      n * n
    end

    def get_binding_and_line
      a = true
      [binding, __LINE__]
    end

    def get_binding
      get_binding_and_line[0]
    end

    def get_line_of_binding
      get_binding_and_line[1]
    end

    def get_file_of_binding
      __FILE__
    end

    def get_empty_binding
      binding
    end

    def get_binding_in_block
      a = true
      1.times do
        b = false
        return binding
      end
    end
  end
end