Class: Puppet::Pops::Types::Mismatch
Instance Attribute Summary collapse
Instance Method Summary
collapse
#it_does_not_expect, #it_expects, #it_has_no
Constructor Details
#initialize(path) ⇒ Mismatch
Returns a new instance of Mismatch.
113
114
115
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 113
def initialize(path)
@path = path || EMPTY_ARRAY
end
|
Instance Attribute Details
111
112
113
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 111
def path
@path
end
|
Instance Method Details
#==(o) ⇒ Object
Also known as:
eql?
129
130
131
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 129
def ==(o)
self.class == o.class && canonical_path == o.canonical_path
end
|
#canonical_path ⇒ Object
117
118
119
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 117
def canonical_path
@canonical_path ||= @path.reject { |e| e.is_a?(VariantPathElement) }
end
|
#chop_path(element_index) ⇒ Object
139
140
141
142
143
144
145
146
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 139
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
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 156
def format(tense)
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, tense)
end
|
135
136
137
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 135
def hash
canonical_path.hash
end
|
#merge(path, o) ⇒ Object
125
126
127
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 125
def merge(path, o)
self.class.new(path)
end
|
#message(variant, position, tense = :present) ⇒ Object
121
122
123
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 121
def message(variant, position, tense = :present)
"#{variant}unknown mismatch#{position}"
end
|
#path_string ⇒ Object
148
149
150
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 148
def path_string
@path.join(' ')
end
|
152
153
154
|
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 152
def to_s
format(:present)
end
|