lib/nrser/types/type.rb
# Load a value of this type from a string representation by passing
# `string` to the {@from_s} {Proc}.
# 
# Checks the value {@from_s} returns with {#check!} before returning it, so
# you know it satisfies this type.
# 
# Realizing classes **should not** need to override this - they can define
# a `#custom_from_s` instance method for it to use, allowing individual
# types to still override that by providing a `from_s:` proc keyword
# arg at construction. This also lets them avoid checking the returned
# value, since we do so here.
# 
# @param [String] string
#   String representation.
# 
# @return [Object]
#   Value that has passed {#check!}.
# 
# @raise [NoMethodError]
#   If this type doesn't know how to load values from strings.
#   
#   In basic types this happens when {NRSER::Types::Type#initialize} was
#   not provided a `from_s:` {Proc} argument.
#   
#   {NRSER::Types::Type} subclasses may override {#from_s} entirely,
#   divorcing it from the `from_s:` constructor argument and internal
#   {@from_s} instance variable (which is why {@from_s} is not publicly
#   exposed - it should not be assumed to dictate {#from_s} behavior
#   in general).
# 
# @raise [TypeError]
#   If the value loaded does not pass {#check}.
# 
Load a value of this type from a string representation by passing
`string` to the  {Proc}.

Checks the value  returns with {#check!} before returning it, so
you know it satisfies this type.

Realizing classes **should not** need to override this - they can define
a `#custom_from_s` instance method for it to use, allowing individual
types to still override that by providing a `from_s:` proc keyword
arg at construction. This also lets them avoid checking the returned
value, since we do so here.
Load a value of this type from a string representation by passing ` string ` to the { Proc } . Checks the value returns with { #check! } before returning it so you know it satisfies this type . Realizing classes ** should not ** need to override this - they can define a ` #custom_from_s ` instance method for it to use allowing individual types to still override that by providing a ` from_s : ` proc keyword arg at construction . This also lets them avoid checking the returned value since we do so here .
def from_s string
    unless has_from_s?
      raise NoMethodError, "#from_s not defined for type #{ name }"
    end
    value = if @from_s
      @from_s.call string
    else
      custom_from_s string
    end
    check! value
  end
def from_s string unless has_from_s? raise NoMethodError , "#from_s not defined for type #{ name }" end value = if @from_s @from_s . call string else custom_from_s string end check! value end
Load a value of this type from a string representation by passing
`string` to the {@from_s} {Proc}.
Load a value of this type from a string representation by passing ` string ` to the { @from_s } { Proc } .
Value that has passed {#check!}.
Value that has passed { #check! } .
Object
[NoMethodError] If this type doesn't know how to load values from strings. In basic types this happens when {NRSER::Types::Type#initialize} was not provided a `from_s:` {Proc} argument. {NRSER::Types::Type} subclasses may override {#from_s} entirely, divorcing it from the `from_s:` constructor argument and internal  instance variable (which is why  is not publicly exposed - it should not be assumed to dictate {#from_s} behavior in general).
[ NoMethodError ] If this type doesn ' t know how to load values from strings . In basic types this happens when { NRSER :: Types :: Type#initialize } was not provided a ` from_s : ` { Proc } argument . { NRSER :: Types :: Type } subclasses may override { #from_s } entirely divorcing it from the ` from_s : ` constructor argument and internal instance variable ( which is why is not publicly exposed - it should not be assumed to dictate { #from_s } behavior in general ) .
[TypeError] If the value loaded does not pass {#check}.
[ TypeError ] If the value loaded does not pass { #check } .
string
<not_specific>
<not_specific>
string String representation.
string String representation .