Class: KeySet::None

Inherits:
KeySet show all
Defined in:
lib/key_set/none.rb

Constant Summary

Constants inherited from KeySet

VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from KeySet

#<=>, #==, #===, all, all_except_some, default_logger, #eql?, #hash, logger, none, #represents_all?, some

Class Method Details

.class_sort_indexObject



5
6
7
# File 'lib/key_set/none.rb', line 5

def self.class_sort_index
  0
end

Instance Method Details

#intersect(other) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/key_set/none.rb', line 37

def intersect(other)
  case other
  when All
    KeySet.none
  when None
    KeySet.none
  when Some
    KeySet.none
  when AllExceptSome
    KeySet.none
  else
    raise ArgumentError, 'it needs a valid KeySet'
  end
end

#invertObject



13
14
15
# File 'lib/key_set/none.rb', line 13

def invert
  KeySet.all
end

#remove(other) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/key_set/none.rb', line 17

def remove(other)
  case other
  when All
    # we have nothing, we remove everything => we have nothing
    KeySet.none
  when None
    # we have nothing, we remove nothing => we have nothing
    KeySet.none
  when Some
    # we have nothing, we remove some => we have nothing
    KeySet.none
  when AllExceptSome
    # we have nothing, we remove all except some => we have nothing
    KeySet.logger.warn "KeySet removing AllButSome, probably a mistake. this: NONE, removing keys: #{other.keys.inspect}"
    KeySet.none
  else
    raise ArgumentError, 'it needs a valid KeySet'
  end
end

#represents_none?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/key_set/none.rb', line 9

def represents_none?
  true
end