Class: InterfaceSpec Private
- Inherits:
-
Object
- Object
- InterfaceSpec
- Defined in:
- lib/interfacer.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #fullfills_interface?(tested_class) ⇒ Boolean private
-
#initialize(required_interface_methods) ⇒ InterfaceSpec
constructor
private
A new instance of InterfaceSpec.
- #missing_methods(tested_class) ⇒ Object private
Constructor Details
#initialize(required_interface_methods) ⇒ InterfaceSpec
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of InterfaceSpec.
3 4 5 |
# File 'lib/interfacer.rb', line 3 def initialize(required_interface_methods) @required_interface_methods = required_interface_methods end |
Instance Method Details
#fullfills_interface?(tested_class) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/interfacer.rb', line 19 def fullfills_interface?(tested_class) self.missing_methods(tested_class).empty? end |
#missing_methods(tested_class) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/interfacer.rb', line 7 def missing_methods(tested_class) @required_interface_methods.reject do |method_name| if method_name[0] == '.' tested_class.respond_to?(method_name[1..-1]) elsif method_name[0] == '#' tested_class.instance_methods.include?(method_name[1..-1].to_sym) else raise ArgumentError.new("Incorrect method name. Method name must start with either . or #, such as .new or #to_s.") end end end |