Class: Puppet::Pops::Types::TypeFormatter

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

Direct Known Subclasses

RubyGenerator

Constant Summary collapse

NAME_SEGMENT_SEPARATOR =
'::'.freeze
STARTS_WITH_ASCII_CAPITAL =
/^[A-Z]/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.singletonTypeCalculator

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 the singleton instance.

Returns:



23
24
25
# File 'lib/puppet/pops/types/type_formatter.rb', line 23

def self.singleton
  @singleton
end

.string(t) ⇒ String

Produces a String representation of the given type.

Parameters:

  • t (PAnyType)

    the type to produce a string form

Returns:

  • (String)

    the type in string form



16
17
18
# File 'lib/puppet/pops/types/type_formatter.rb', line 16

def self.string(t)
  @singleton.string(t)
end

Instance Method Details

#alias_expanded_string(t) ⇒ Object

Produces a string representing the type where type aliases have been expanded



94
95
96
97
98
99
100
101
# File 'lib/puppet/pops/types/type_formatter.rb', line 94

def alias_expanded_string(t)
  @expanded = true
  begin
    string(t)
  ensure
    @expanded = false
  end
end

#append_callable_params(t) ⇒ Object



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/puppet/pops/types/type_formatter.rb', line 255

def append_callable_params(t)
  # translate to string, and skip Unit types
  append_strings(t.param_types.types.reject {|t2| t2.class == PUnitType }, true)

  if t.param_types.types.empty?
    append_strings([0, 0], true)
  else
    append_elements(range_array_part(t.param_types.size_type), true)
  end

  # Add block T last (after min, max) if present)
  #
  append_strings([t.block_type], true) unless t.block_type.nil?
  chomp_list
end

#append_defaultObject



72
73
74
# File 'lib/puppet/pops/types/type_formatter.rb', line 72

def append_default
  @bld << 'default'
end

#append_string(t) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/puppet/pops/types/type_formatter.rb', line 76

def append_string(t)
  if @ruby && t.is_a?(PAnyType)
    @ruby = false
    begin
      @bld << @ref_ctor << "('"
      @@string_visitor.visit_this_0(self, t)
      @bld << "')"
    ensure
      @ruby = true
    end
  else
    @@string_visitor.visit_this_0(self, t)
  end
end

#capitalize_segments(qualified_name) ⇒ String

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.

Capitalizes each segment in a name separated with the NAME_SEPARATOR conditionally. The name will not be subject to capitalization if it already starts with a capital letter. This to avoid that existing camel casing is lost.

Parameters:

  • qualified_name (String)

    the name to capitalize

Returns:

  • (String)

    the capitalized name



532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/puppet/pops/types/type_formatter.rb', line 532

def capitalize_segments(qualified_name)
  if !qualified_name.is_a?(String) || qualified_name =~ STARTS_WITH_ASCII_CAPITAL
    qualified_name
  else
    segments = qualified_name.split(NAME_SEGMENT_SEPARATOR)
    if segments.size == 1
      qualified_name.capitalize
    else
      segments.each(&:capitalize!)
      segments.join(NAME_SEGMENT_SEPARATOR)
    end
  end
end

#debug_string(t) ⇒ Object

Produces a debug string representing the type (possibly with more information that the regular string format)



106
107
108
109
110
111
112
113
# File 'lib/puppet/pops/types/type_formatter.rb', line 106

def debug_string(t)
  @debug = true
  begin
    string(t)
  ensure
    @debug = false
  end
end

#indented_string(t, indent = 0, indent_width = 2) ⇒ Object

Produces an string containing newline characters and indentation that represents the given type or literal t.

Parameters:

  • t (Object)

    the type or literal to produce a string for

  • indent (Integer) (defaults to: 0)

    the current indentation level

  • indent_width (Integer) (defaults to: 2)

    the number of spaces to use for one indentation



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/puppet/pops/types/type_formatter.rb', line 44

def indented_string(t, indent = 0, indent_width = 2)
  @indent = indent
  @indent_width = indent_width
  begin
    @bld = ''
    (@indent * @indent_width).times { @bld << ' ' }
    append_string(t)
    @bld << "\n"
    @bld
  ensure
    @indent = nil
    @indent_width = nil
  end
end

#ruby_string(ref_ctor, indent, t) ⇒ 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.



60
61
62
63
64
65
66
67
68
69
# File 'lib/puppet/pops/types/type_formatter.rb', line 60

def ruby_string(ref_ctor, indent, t)
  @ruby = true
  @ref_ctor = ref_ctor
  begin
    indented_string(t, indent)
  ensure
    @ruby = nil
    @ref_ctor = nil
  end
end

#string(t) ⇒ Object

Produces a string representing the type



30
31
32
33
34
# File 'lib/puppet/pops/types/type_formatter.rb', line 30

def string(t)
  @bld = ''
  append_string(t)
  @bld
end

#string_Array(t) ⇒ 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.



466
467
468
# File 'lib/puppet/pops/types/type_formatter.rb', line 466

def string_Array(t)
  append_array('') { append_strings(t) }
end

#string_FalseClass(t) ⇒ 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.



471
# File 'lib/puppet/pops/types/type_formatter.rb', line 471

def string_FalseClass(t)   ; @bld << 'false'       ; end

#string_Hash(t) ⇒ 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.



474
475
476
# File 'lib/puppet/pops/types/type_formatter.rb', line 474

def string_Hash(t)
  append_hash(t)
end

#string_Module(t) ⇒ 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.



479
480
481
# File 'lib/puppet/pops/types/type_formatter.rb', line 479

def string_Module(t)
  append_string(TypeCalculator.singleton.type(t))
end

#string_NilClass(t) ⇒ 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.



484
# File 'lib/puppet/pops/types/type_formatter.rb', line 484

def string_NilClass(t)     ; @bld << (@ruby ? 'nil' : '?') ; end

#string_Numeric(t) ⇒ 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.



487
# File 'lib/puppet/pops/types/type_formatter.rb', line 487

def string_Numeric(t)      ; @bld << t.to_s    ; end

#string_PAnnotatedMember(m) ⇒ 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.



368
369
370
371
372
373
374
375
# File 'lib/puppet/pops/types/type_formatter.rb', line 368

def string_PAnnotatedMember(m)
  hash = m.i12n_hash
  if hash.size == 1
    string(m.type)
  else
    string(hash)
  end
end

#string_PAnyType(_) ⇒ 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.



116
# File 'lib/puppet/pops/types/type_formatter.rb', line 116

def string_PAnyType(_)     ; @bld << 'Any'     ; end

#string_PArrayType(t) ⇒ 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.



311
312
313
314
315
316
317
318
319
320
321
# File 'lib/puppet/pops/types/type_formatter.rb', line 311

def string_PArrayType(t)
  if t.has_empty_range?
    append_array('Array') { append_strings([0, 0]) }
  else
    append_array('Array', t == PArrayType::DATA) do
      append_strings([t.element_type], true)
      append_elements(range_array_part(t.size_type), true)
      chomp_list
    end
  end
end

#string_PBinaryType(_) ⇒ 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.



137
# File 'lib/puppet/pops/types/type_formatter.rb', line 137

def string_PBinaryType(_)  ; @bld << 'Binary' ; end

#string_PBooleanType(_) ⇒ 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.



125
# File 'lib/puppet/pops/types/type_formatter.rb', line 125

def string_PBooleanType(_) ; @bld << 'Boolean' ; end

#string_PCallableType(t) ⇒ 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.



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/puppet/pops/types/type_formatter.rb', line 239

def string_PCallableType(t)
  if t.return_type.nil?
    append_array('Callable', t.param_types.nil?) { append_callable_params(t) }
  else
    if t.param_types.nil?
      append_array('Callable', false) { append_strings([[], t.return_type], false) }
    else
      append_array('Callable', false) do
        append_array('', false) { append_callable_params(t) }
        @bld << COMMA_SEP
        append_string(t.return_type)
      end
    end
  end
end

#string_PCatalogEntryType(_) ⇒ 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.



337
338
339
# File 'lib/puppet/pops/types/type_formatter.rb', line 337

def string_PCatalogEntryType(_)
  @bld << 'CatalogEntry'
end

#string_PCollectionType(t) ⇒ 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.



295
296
297
298
# File 'lib/puppet/pops/types/type_formatter.rb', line 295

def string_PCollectionType(t)
  range = range_array_part(t.size_type)
  append_array('Collection', range.empty? ) { append_elements(range) }
end

#string_PDataType(_) ⇒ 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.



131
# File 'lib/puppet/pops/types/type_formatter.rb', line 131

def string_PDataType(_)    ; @bld << 'Data'    ; end

#string_PDefaultType(_) ⇒ 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.



122
# File 'lib/puppet/pops/types/type_formatter.rb', line 122

def string_PDefaultType(_) ; @bld << 'Default' ; end

#string_PEnumType(t) ⇒ 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.



184
185
186
# File 'lib/puppet/pops/types/type_formatter.rb', line 184

def string_PEnumType(t)
  append_array('Enum', t.values.empty?) { append_strings(t.values) }
end

#string_PFloatType(t) ⇒ 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.



160
161
162
# File 'lib/puppet/pops/types/type_formatter.rb', line 160

def string_PFloatType(t)
  append_array('Float', t.unbounded? ) { append_elements(range_array_part(t)) }
end

#string_PHashType(t) ⇒ 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.



324
325
326
327
328
329
330
331
332
333
334
# File 'lib/puppet/pops/types/type_formatter.rb', line 324

def string_PHashType(t)
  if t.has_empty_range?
    append_array('Hash') { append_strings([0, 0]) }
  else
    append_array('Hash', t == PHashType::DATA) do
      append_strings([t.key_type, t.element_type], true)
      append_elements(range_array_part(t.size_type), true)
      chomp_list
    end
  end
end

#string_PHostClassType(t) ⇒ 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.



342
343
344
# File 'lib/puppet/pops/types/type_formatter.rb', line 342

def string_PHostClassType(t)
  append_array('Class', t.class_name.nil?) { append_elements([t.class_name]) }
end

#string_PIntegerType(t) ⇒ 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.



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

def string_PIntegerType(t)
  append_array('Integer', t.unbounded?) { append_elements(range_array_part(t)) }
end

#string_PIterableType(t) ⇒ 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.



150
151
152
# File 'lib/puppet/pops/types/type_formatter.rb', line 150

def string_PIterableType(t)
  append_array('Iterable', t.element_type.nil?)  { append_string(t.element_type) }
end

#string_PIteratorType(t) ⇒ 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.



155
156
157
# File 'lib/puppet/pops/types/type_formatter.rb', line 155

def string_PIteratorType(t)
  append_array('Iterator', t.element_type.nil?) { append_string(t.element_type) }
end

#string_PNotUndefType(t) ⇒ 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.



356
357
358
359
360
361
362
363
364
365
# File 'lib/puppet/pops/types/type_formatter.rb', line 356

def string_PNotUndefType(t)
  contained_type = t.type
  append_array('NotUndef', contained_type.nil? || contained_type.class == PAnyType) do
    if contained_type.is_a?(PStringType) && contained_type.values.size == 1
      append_string(contained_type.values[0])
    else
      append_string(contained_type)
    end
  end
end

#string_PNumericType(_) ⇒ 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.



134
# File 'lib/puppet/pops/types/type_formatter.rb', line 134

def string_PNumericType(_) ; @bld << 'Numeric' ; end

#string_PObjectType(t) ⇒ 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.



413
414
415
416
417
418
419
# File 'lib/puppet/pops/types/type_formatter.rb', line 413

def string_PObjectType(t)
  if @expanded
    append_object_hash(t.i12n_hash(@type_set.nil? || !@type_set.defines_type?(t)))
  else
    @bld << (@type_set ? @type_set.name_for(t) : t.label)
  end
end

#string_POptionalType(t) ⇒ 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.



427
428
429
430
431
432
433
434
435
436
# File 'lib/puppet/pops/types/type_formatter.rb', line 427

def string_POptionalType(t)
  optional_type = t.optional_type
  append_array('Optional', optional_type.nil?) do
    if optional_type.is_a?(PStringType) && optional_type.values.size == 1
      append_string(optional_type.values[0])
    else
      append_string(optional_type)
    end
  end
end

#string_PPatternType(t) ⇒ 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.



290
291
292
# File 'lib/puppet/pops/types/type_formatter.rb', line 290

def string_PPatternType(t)
  append_array('Pattern', t.patterns.empty?) { append_strings(t.patterns.map(&:regexp)) }
end

#string_PRegexpType(t) ⇒ 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.



165
166
167
# File 'lib/puppet/pops/types/type_formatter.rb', line 165

def string_PRegexpType(t)
  append_array('Regexp', t.pattern.nil?) { append_string(t.regexp) }
end

#string_PResourceType(t) ⇒ 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.



347
348
349
350
351
352
353
# File 'lib/puppet/pops/types/type_formatter.rb', line 347

def string_PResourceType(t)
  if t.type_name
    append_array(capitalize_segments(t.type_name), t.title.nil?) { append_string(t.title) }
  else
    @bld << 'Resource'
  end
end

#string_PRuntimeType(t) ⇒ 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.



306
307
308
# File 'lib/puppet/pops/types/type_formatter.rb', line 306

def string_PRuntimeType(t)
  append_array('Runtime') { append_strings([t.runtime, t.name_or_pattern]) }
end

#string_PScalarType(_) ⇒ 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.



128
# File 'lib/puppet/pops/types/type_formatter.rb', line 128

def string_PScalarType(_)  ; @bld << 'Scalar'  ; end

#string_PSemVerRangeType(t) ⇒ 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.



199
200
201
# File 'lib/puppet/pops/types/type_formatter.rb', line 199

def string_PSemVerRangeType(t)
  @bld << 'SemVerRange'
end

#string_PSemVerType(t) ⇒ 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.



194
195
196
# File 'lib/puppet/pops/types/type_formatter.rb', line 194

def string_PSemVerType(t)
  append_array('SemVer', t.ranges.empty?) { append_strings(t.ranges) }
end

#string_PSensitiveType(t) ⇒ 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.



422
423
424
# File 'lib/puppet/pops/types/type_formatter.rb', line 422

def string_PSensitiveType(t)
  append_array('Sensitive') { append_string(t.type) }
end

#string_PStringType(t) ⇒ 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.



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/puppet/pops/types/type_formatter.rb', line 170

def string_PStringType(t)
  range = range_array_part(t.size_type)
  append_array('String', range.empty?) do
    if @debug
      append_elements(range, true)
      append_strings(t.values, true)
      chomp_list
    else
      append_elements(range)
    end
  end
end

#string_PStructType(t) ⇒ 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.



272
273
274
# File 'lib/puppet/pops/types/type_formatter.rb', line 272

def string_PStructType(t)
  append_array('Struct', t.elements.empty?) { append_hash(Hash[t.elements.map {|e| struct_element_pair(e) }]) }
end

#string_PTimespanType(t) ⇒ 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.



217
218
219
220
221
222
223
224
225
226
227
# File 'lib/puppet/pops/types/type_formatter.rb', line 217

def string_PTimespanType(t)
  min = t.from
  max = t.to
  append_array('Timespan', min.nil? && max.nil?) do
    min.nil? ? append_default : append_string(min)
    unless max.nil? || max == min
      @bld << COMMA_SEP
      append_string(max)
    end
  end
end

#string_PTimestampType(t) ⇒ 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.



204
205
206
207
208
209
210
211
212
213
214
# File 'lib/puppet/pops/types/type_formatter.rb', line 204

def string_PTimestampType(t)
  min = t.from
  max = t.to
  append_array('Timestamp', min.nil? && max.nil?) do
    min.nil? ? append_default : append_string(min)
    unless max.nil? || max == min
      @bld << COMMA_SEP
      append_string(max)
    end
  end
end

#string_PTupleType(t) ⇒ 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.



230
231
232
233
234
235
236
# File 'lib/puppet/pops/types/type_formatter.rb', line 230

def string_PTupleType(t)
  append_array('Tuple', t.types.empty?) do
    append_strings(t.types, true)
    append_elements(range_array_part(t.size_type), true)
    chomp_list
  end
end

#string_PType(t) ⇒ 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.



145
146
147
# File 'lib/puppet/pops/types/type_formatter.rb', line 145

def string_PType(t)
  append_array('Type', t.type.nil?) { append_string(t.type) }
end

#string_PTypeAliasType(t) ⇒ 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.



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/puppet/pops/types/type_formatter.rb', line 439

def string_PTypeAliasType(t)
  expand = @expanded
  if expand && t.self_recursion?
    @guard ||= RecursionGuard.new
    expand = (@guard.add_this(t) & RecursionGuard::SELF_RECURSION_IN_THIS) == 0
  end
  if @type_set.nil?
    @bld << t.name
    if expand
      @bld << ' = '
      append_string(t.resolved_type)
    end
  else
    if expand && @type_set.defines_type?(t)
      append_string(t.resolved_type)
    else
      @bld << @type_set.name_for(t)
    end
  end
end

#string_PTypeReferenceType(t) ⇒ 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.



461
462
463
# File 'lib/puppet/pops/types/type_formatter.rb', line 461

def string_PTypeReferenceType(t)
  append_array('TypeReference') { append_string(t.type_string) }
end

#string_PTypeSetType(t) ⇒ 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.



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/puppet/pops/types/type_formatter.rb', line 385

def string_PTypeSetType(t)
  append_array('TypeSet') do
    append_hash(t.i12n_hash.each, proc { |k| @bld << symbolic_key(k) }) do |k,v|
      case k
      when KEY_TYPES
        old_ts = @type_set
        @type_set = t
        begin
          append_hash(v, proc { |tk| @bld << symbolic_key(tk) }) do |tk, tv|
            if tv.is_a?(Hash)
              append_object_hash(tv)
            else
              append_string(tv)
            end
          end
        rescue
          @type_set = old_ts
        end
      when KEY_REFERENCES
        append_hash(v, proc { |tk| @bld << symbolic_key(tk) })
      else
        append_string(v)
      end
    end
  end
end

#string_PUndefType(_) ⇒ 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.



119
# File 'lib/puppet/pops/types/type_formatter.rb', line 119

def string_PUndefType(_)   ; @bld << 'Undef'   ; end

#string_PUnitType(_) ⇒ 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.



301
302
303
# File 'lib/puppet/pops/types/type_formatter.rb', line 301

def string_PUnitType(_)
  @bld << 'Unit'
end

#string_PVariantType(t) ⇒ 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.



189
190
191
# File 'lib/puppet/pops/types/type_formatter.rb', line 189

def string_PVariantType(t)
  append_array('Variant', t.types.empty?) { append_strings(t.types) }
end

#string_Regexp(t) ⇒ 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.



490
# File 'lib/puppet/pops/types/type_formatter.rb', line 490

def string_Regexp(t)       ; @bld << t.inspect; end

#string_String(t) ⇒ 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.



493
494
495
496
# File 'lib/puppet/pops/types/type_formatter.rb', line 493

def string_String(t)
  # Use single qoute on strings that does not contain single quotes, control characters, or backslashes.
  @bld << StringConverter.singleton.puppet_quote(t)
end

#string_Symbol(t) ⇒ 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.



499
# File 'lib/puppet/pops/types/type_formatter.rb', line 499

def string_Symbol(t)       ; @bld << t.to_s    ; end

#string_Timespan(t) ⇒ 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.



511
# File 'lib/puppet/pops/types/type_formatter.rb', line 511

def string_Timespan(t)    ; @bld << "'#{t}'"  ; end

#string_Timestamp(t) ⇒ 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.



514
# File 'lib/puppet/pops/types/type_formatter.rb', line 514

def string_Timestamp(t)    ; @bld << "'#{t}'"  ; end

#string_TrueClass(t) ⇒ 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.



502
# File 'lib/puppet/pops/types/type_formatter.rb', line 502

def string_TrueClass(t)    ; @bld << 'true'    ; end

#string_Version(t) ⇒ 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.



505
# File 'lib/puppet/pops/types/type_formatter.rb', line 505

def string_Version(t)      ; @bld << "'#{t}'"  ; end

#string_VersionRange(t) ⇒ 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.



508
# File 'lib/puppet/pops/types/type_formatter.rb', line 508

def string_VersionRange(t) ; @bld << "'#{t}'"  ; end

#struct_element_pair(t) ⇒ 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.



277
278
279
280
281
282
283
284
285
286
287
# File 'lib/puppet/pops/types/type_formatter.rb', line 277

def struct_element_pair(t)
  k = t.key_type
  value_optional = t.value_type.assignable?(PUndefType::DEFAULT)
  if k.is_a?(POptionalType)
    # Output as literal String
    k = t.name if value_optional
  else
    k = value_optional ? PNotUndefType.new(k) : t.name
  end
  [k, t.value_type]
end

#symbolic_key(key) ⇒ 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.

Used when printing names of well known keys in an Object type. Placed in a separate method to allow override.



380
381
382
# File 'lib/puppet/pops/types/type_formatter.rb', line 380

def symbolic_key(key)
  @ruby ? "'#{key}'" : key
end

#to_sObject

Debugging to_s to reduce the amount of output



517
518
519
# File 'lib/puppet/pops/types/type_formatter.rb', line 517

def to_s
  '[a TypeFormatter]'
end