Class: Dhall::Util::HashOf

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/util.rb

Instance Method Summary collapse

Constructor Details

#initialize(key_validator, element_validator, min: 0, max: Float::INFINITY) ⇒ HashOf

Returns a new instance of HashOf.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/dhall/util.rb', line 30

def initialize(
  key_validator,
  element_validator,
  min: 0,
  max: Float::INFINITY
)
  @min = min
  @max = max
  @key_validator = key_validator
  @element_validator = element_validator
end

Instance Method Details

#===(other) ⇒ Object



42
43
44
45
46
47
# File 'lib/dhall/util.rb', line 42

def ===(other)
  Hash === other &&
    other.keys.all? { |x| @key_validator === x } &&
    other.values.all? { |x| @element_validator === x } &&
    other.size >= @min && other.size <= @max
end