Module: Puppet::Pops::LabelProvider

Included in:
Binder::BindingsLabelProvider, Model::ModelLabelProvider, Types::TypeMismatch
Defined in:
lib/puppet/pops/label_provider.rb

Overview

Provides a label for an object. This simple implementation calls #to_s on the given object, and handles articles ‘a/an/the’.

Constant Summary collapse

VOWELS =
%w{a e i o u y}
SKIPPED_CHARACTERS =
%w{" '}
A =
"a"
AN =
"an"

Instance Method Summary collapse

Instance Method Details

#a_an(o) ⇒ Object

Produces a label for the given text with indefinite article (a/an)



17
18
19
20
# File 'lib/puppet/pops/label_provider.rb', line 17

def a_an o
  text = label(o)
  "#{article(text)} #{text}"
end

#a_an_uc(o) ⇒ Object

Produces a label for the given text with indefinite article (A/An)



23
24
25
26
# File 'lib/puppet/pops/label_provider.rb', line 23

def a_an_uc o
  text = label(o)
  "#{article(text).capitalize} #{text}"
end

#label(o) ⇒ Object

Provides a label for the given object by calling ‘to_s` on the object. The intent is for this method to be overridden in concrete label providers.



12
13
14
# File 'lib/puppet/pops/label_provider.rb', line 12

def label o
  o.to_s
end

#plural_s(count, text = '') ⇒ Object

Appends ‘s’ to (optional) text if count != 1 else an empty string



39
40
41
# File 'lib/puppet/pops/label_provider.rb', line 39

def plural_s(count, text = '')
  count == 1 ? text : "#{text}s"
end

#the(o) ⇒ Object

Produces a label for the given text with *definitie article* (the).



29
30
31
# File 'lib/puppet/pops/label_provider.rb', line 29

def the o
  "the #{label(o)}"
end

#the_uc(o) ⇒ Object

Produces a label for the given text with *definitie article* (The).



34
35
36
# File 'lib/puppet/pops/label_provider.rb', line 34

def the_uc o
  "The #{label(o)}"
end