class NRSER::Types::Maybe

Definitions

Attributes

type[R]

The type of all members besides `nil`.

@return [Type]

Public Class Methods

new(type, **options) click to toggle source

Instantiate a new `NRSER::Types::Maybe`.

Calls superclass method
# File lib/nrser/types/maybe.rb, line 36
def initialize type, **options
  super **options
  @type = NRSER::Types.make type
end

Public Instance Methods

custom_from_s(string) click to toggle source
# File lib/nrser/types/maybe.rb, line 60
def custom_from_s string
  type.from_s string
end
explain() click to toggle source
# File lib/nrser/types/maybe.rb, line 50
def explain
  "#{ @type.name }?"
end
has_from_s?() click to toggle source
# File lib/nrser/types/maybe.rb, line 55
def has_from_s?
  !@from_s.nil? || type.has_from_s?
end
test?(value) click to toggle source

Instance Methods

# File lib/nrser/types/maybe.rb, line 45
def test? value
  value.nil? || @type.test?( value )
end