Class: DocTypeChecker::Definition
- Inherits:
-
Object
- Object
- DocTypeChecker::Definition
- Defined in:
- lib/doc_type_checker/definition.rb
Overview
DocTypeChecker::Definition
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#ret ⇒ Object
readonly
Returns the value of attribute ret.
Instance Method Summary collapse
- #initialize(method_object) ⇒ DocTypeChecker::Definition constructor
- #validate_params(arguments) ⇒ Array<String>
- #validate_return(object) ⇒ String, NilClass
Constructor Details
#initialize(method_object) ⇒ DocTypeChecker::Definition
10 11 12 13 14 |
# File 'lib/doc_type_checker/definition.rb', line 10 def initialize(method_object) @name = method_object.path init_params(method_object) init_return(method_object) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/doc_type_checker/definition.rb', line 6 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/doc_type_checker/definition.rb', line 6 def params @params end |
#ret ⇒ Object (readonly)
Returns the value of attribute ret.
6 7 8 |
# File 'lib/doc_type_checker/definition.rb', line 6 def ret @ret end |
Instance Method Details
#validate_params(arguments) ⇒ Array<String>
18 19 20 21 22 23 24 25 |
# File 'lib/doc_type_checker/definition.rb', line 18 def validate_params(arguments) params.filter_map do |key, value| object = arguments[key] unless value.valid_type(object) "#{name}: #{key} isn't any of #{value.inspect_type}. actual type is #{object.class}" end end end |
#validate_return(object) ⇒ String, NilClass
29 30 31 32 33 |
# File 'lib/doc_type_checker/definition.rb', line 29 def validate_return(object) return if !ret.types.empty? && ret.valid_type(object) "#{name}: return value isn't any of #{ret.inspect_type}. actual type is #{object.class}" end |