Class: Puppet::Pops::Types::Mismatch Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/types/type_mismatch_describer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Mismatch

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Mismatch.

API:

  • private



99
100
101
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 99

def initialize(path)
  @path = path || EMPTY_ARRAY
end

Instance Attribute Details

#pathObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



97
98
99
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 97

def path
  @path
end

Instance Method Details

#==(o) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



115
116
117
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 115

def ==(o)
  self.class == o.class && canonical_path == o.canonical_path
end

#canonical_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



103
104
105
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 103

def canonical_path
  @canonical_path ||= @path.reject { |e| e.is_a?(VariantPathElement) }
end

#chop_path(element_index) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



127
128
129
130
131
132
133
134
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 127

def chop_path(element_index)
  return self if element_index >= @path.size
  chopped_path = @path.clone
  chopped_path.delete_at(element_index)
  copy = self.clone
  copy.instance_variable_set(:@path, chopped_path)
  copy
end

#eql?(o) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

API:

  • private



119
120
121
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 119

def eql?(o)
  self == o
end

#formatObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 144

def format
  p = @path
  variant = ''
  position = ''
  unless p.empty?
    f = p.first
    if f.is_a?(SignaturePathElement)
      variant = " #{f}"
      p = p.drop(1)
    end
    position = " #{p.join(' ')}" unless p.empty?
  end
  message(variant, position)
end

#hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



123
124
125
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 123

def hash
  canonical_path.hash
end

#merge(path, o) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



111
112
113
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 111

def merge(path, o)
  self.class.new(path)
end

#message(variant, position) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



107
108
109
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 107

def message(variant, position)
  "#{variant}unknown mismatch#{position}"
end

#path_stringObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



136
137
138
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 136

def path_string
  @path.join(' ')
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



140
141
142
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 140

def to_s
  format
end