Module: I8

Defined in:
lib/nrser/labs/i8.rb,
lib/nrser/labs/i8/struct.rb,
lib/nrser/labs/i8/surjection.rb,
lib/nrser/labs/i8/struct/hash.rb,
lib/nrser/labs/i8/struct/vector.rb

Overview

Namespace

Defined Under Namespace

Modules: Struct Classes: Hash, Set, SortedSet, Surjection, Vector

Class Method Summary collapse

Class Method Details

.[](value) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/nrser/labs/i8.rb', line 93

def self.[] value
  case value
  when  Hamster::Hash,
        Hamster::Vector,
        Hamster::Set,
        Hamster::SortedSet,
        Hamster::List
    value
  when ::Hash
    I8::Hash[value]
  when ::Array
    I8::Vector.new value
  when ::Set
    I8::Set.new value
  when ::SortedSet
    I8::SortedSet.new value
  else
    raise NRSER::TypeError.new \
      "Value must be Hash, Array, Set or SortedSet",
      found: value
  end
end