Class: MockSuey::TypeChecks::Ruby::SignatureGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/mock_suey/type_checks/ruby.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, method_calls) ⇒ SignatureGenerator

Returns a new instance of SignatureGenerator.



21
22
23
24
25
26
# File 'lib/mock_suey/type_checks/ruby.rb', line 21

def initialize(klass, method_calls)
  @klass = klass
  @singleton = klass.singleton_class?
  @method_calls = method_calls
  @constants = Set.new
end

Instance Attribute Details

#constantsObject (readonly)

Returns the value of attribute constants.



18
19
20
# File 'lib/mock_suey/type_checks/ruby.rb', line 18

def constants
  @constants
end

#klassObject (readonly)

Returns the value of attribute klass.



18
19
20
# File 'lib/mock_suey/type_checks/ruby.rb', line 18

def klass
  @klass
end

#method_callsObject (readonly)

Returns the value of attribute method_calls.



18
19
20
# File 'lib/mock_suey/type_checks/ruby.rb', line 18

def method_calls
  @method_calls
end

#singletonObject (readonly) Also known as: singleton?

Returns the value of attribute singleton.



18
19
20
# File 'lib/mock_suey/type_checks/ruby.rb', line 18

def singleton
  @singleton
end

Instance Method Details

#to_rbsObject



28
29
30
31
32
33
34
# File 'lib/mock_suey/type_checks/ruby.rb', line 28

def to_rbs
  [
    header,
    *method_calls.map { |name, calls| method_sig(name, calls) },
    footer
  ].join("\n")
end