Class: NRSER::Types::Maybe
Overview
Definitions
Instance Attribute Summary collapse
-
#type ⇒ Type
readonly
The type of all members besides ‘nil`.
Instance Method Summary collapse
- #custom_from_s(string) ⇒ Object
- #explain ⇒ Object
- #has_from_s? ⇒ Boolean
-
#initialize(type, **options) ⇒ Maybe
constructor
Instantiate a new ‘NRSER::Types::Maybe`.
-
#test?(value) ⇒ Boolean
Instance Methods ========================================================================.
Methods inherited from Type
#===, #builtin_inspect, #check, #check!, #default_name, #default_symbolic, #from_data, #from_s, #has_from_data?, #has_to_data?, #inspect, #intersection, #name, #not, #respond_to?, #symbolic, #test, #to_data, #to_proc, #to_s, #union, #xor
Constructor Details
Instance Attribute Details
#type ⇒ Type (readonly)
The type of all members besides ‘nil`.
29 30 31 |
# File 'lib/nrser/types/maybe.rb', line 29 def type @type end |
Instance Method Details
#custom_from_s(string) ⇒ Object
60 61 62 |
# File 'lib/nrser/types/maybe.rb', line 60 def custom_from_s string type.from_s string end |
#explain ⇒ Object
50 51 52 |
# File 'lib/nrser/types/maybe.rb', line 50 def explain "#{ @type.name }?" end |
#has_from_s? ⇒ Boolean
55 56 57 |
# File 'lib/nrser/types/maybe.rb', line 55 def has_from_s? !@from_s.nil? || type.has_from_s? end |
#test?(value) ⇒ Boolean
Instance Methods
45 46 47 |
# File 'lib/nrser/types/maybe.rb', line 45 def test? value value.nil? || @type.test?( value ) end |