Class: Eapi::TypeChecker
- Inherits:
-
Object
- Object
- Eapi::TypeChecker
- Defined in:
- lib/eapi/type_checker.rb
Instance Attribute Summary collapse
-
#allow_raw ⇒ Object
readonly
Returns the value of attribute allow_raw.
-
#given_type ⇒ Object
readonly
Returns the value of attribute given_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(given_type, allow_raw = false) ⇒ TypeChecker
constructor
A new instance of TypeChecker.
- #is_valid_type?(value) ⇒ Boolean
Constructor Details
#initialize(given_type, allow_raw = false) ⇒ TypeChecker
Returns a new instance of TypeChecker.
18 19 20 21 |
# File 'lib/eapi/type_checker.rb', line 18 def initialize(given_type, allow_raw = false) @given_type = given_type @allow_raw = allow_raw end |
Instance Attribute Details
#allow_raw ⇒ Object (readonly)
Returns the value of attribute allow_raw.
16 17 18 |
# File 'lib/eapi/type_checker.rb', line 16 def allow_raw @allow_raw end |
#given_type ⇒ Object (readonly)
Returns the value of attribute given_type.
16 17 18 |
# File 'lib/eapi/type_checker.rb', line 16 def given_type @given_type end |
Class Method Details
.constant_for_type(type) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/eapi/type_checker.rb', line 4 def self.constant_for_type(type) if type.kind_of? Module type else begin type.to_s.constantize rescue NameError nil end end end |
Instance Method Details
#is_valid_type?(value) ⇒ Boolean
23 24 25 |
# File 'lib/eapi/type_checker.rb', line 23 def is_valid_type?(value) value.nil? || valid_raw?(value) || is_same_type?(value) || poses_as_type?(value) end |