Class: NRSER::Types::HashType

Inherits:
IsA show all
Defined in:
lib/nrser/types/hashes.rb

Overview

Note:

Construct HashType types using the Hash factory.

A type who’s members simply are Hash instances.

Implements Type#from_s to provide JSON/YAML detection, as well as “simple” loading aimed at CLI option values.

Direct Known Subclasses

HashOfType

Instance Attribute Summary

Attributes inherited from IsA

#mod

Instance Method Summary collapse

Methods inherited from IsA

#==, #custom_from_data, #explain, #has_from_data?, #init_from_data?, #test?

Methods inherited from Type

#===, #builtin_inspect, #check, #check!, #default_name, #explain, #from_data, #from_s, #has_from_data?, #has_from_s?, #has_to_data?, #inspect, #intersection, #name, #not, #respond_to?, #symbolic, #test, #test?, #to_data, #to_proc, #to_s, #union, #xor

Constructor Details

#initialize(**options) ⇒ HashType

Instantiate a new ‘HashType`.



37
38
39
# File 'lib/nrser/types/hashes.rb', line 37

def initialize **options
  super ::Hash, **options
end

Instance Method Details

#default_symbolicObject



61
62
63
# File 'lib/nrser/types/hashes.rb', line 61

def default_symbolic
  "{#{ keys.symbolic }#{ ASSOC }#{ values.symbolic }}"
end

#keysNRSER::Types::Type

In order to provide the same interface as NRSER::Types::HashOfType, this method always returns NRSER::Types.any.

Returns:



50
# File 'lib/nrser/types/hashes.rb', line 50

def keys; NRSER::Types.Top; end

#valuesNRSER::Types::Type

In order to provide the same interface as NRSER::Types::HashOfType, this method always returns NRSER::Types.any.

Returns:



58
# File 'lib/nrser/types/hashes.rb', line 58

def values; NRSER::Types.Top; end