Class: Hocon::Impl::MemoKey

Inherits:
Object
  • Object
show all
Defined in:
lib/hocon/impl/memo_key.rb

Instance Method Summary collapse

Constructor Details

#initialize(value, restrict_to_child_or_nil) ⇒ MemoKey

Returns a new instance of MemoKey.



8
9
10
11
# File 'lib/hocon/impl/memo_key.rb', line 8

def initialize(value, restrict_to_child_or_nil)
  @value = value
  @restrict_to_child_or_nil = restrict_to_child_or_nil
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hocon/impl/memo_key.rb', line 22

def ==(other)
  if other.is_a?(self.class)
    o = other
    if !o.value.equal?(@value)
      return false
    elsif o.restrict_to_child_or_nil.equals(@restrict_to_child_or_nil)
      return true
    elsif o.restrict_to_child_or_nil == nil || @restrict_to_child_or_nil == nil
      return false
    else
      return o.restrict_to_child_or_nil == @restrict_to_child_or_nil
    end
  else
    false
  end
end

#hashObject



13
14
15
16
17
18
19
20
# File 'lib/hocon/impl/memo_key.rb', line 13

def hash
  h = @value.hash
  if @restrict_to_child_or_nil != nil
    h + 41 * (41 + @restrict_to_child_or_nil.hash)
  else
    h
  end
end

#to_sObject



39
40
41
# File 'lib/hocon/impl/memo_key.rb', line 39

def to_s
  "MemoKey(#{@value}@#{@value.hash},#{@restrict_to_child_or_nil})"
end