403Webshell
Server IP : 104.21.14.103  /  Your IP : 3.144.248.122
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/label_provider.rb
# Provides a label for an object.
# This simple implementation calls #to_s on the given object, and handles articles 'a/an/the'.
#
module Puppet::Pops::LabelProvider
  VOWELS = %w{a e i o u y}
  SKIPPED_CHARACTERS = %w{" '}
  A = "a"
  AN = "an"

  # 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.
  def label o
    o.to_s
  end

  # Produces a label for the given text with indefinite article (a/an)
  def a_an o
    text = label(o)
    "#{article(text)} #{text}"
  end

  # Produces a label for the given text with indefinite article (A/An)
  def a_an_uc o
    text = label(o)
    "#{article(text).capitalize} #{text}"
  end

  # Produces a label for the given text with *definite article* (the).
  def the o
    "the #{label(o)}"
  end

  # Produces a label for the given text with *definite article* (The).
  def the_uc o
    "The #{label(o)}"
  end

  # Appends 's' to (optional) text if count != 1 else an empty string
  def plural_s(count, text = '')
    count == 1 ? text : "#{text}s"
  end

  # Combines several strings using commas and a final conjunction
  def combine_strings(strings, conjunction = 'or')
    case strings.size
    when 0
      ''
    when 1
      strings[0]
    when 2
      "#{strings[0]} #{conjunction} #{strings[1]}"
    else
      "#{strings[0...-1].join(', ')}, #{conjunction} #{strings.last}"
    end
  end

  # Produces an *indefinite article* (a/an) for the given text ('a' if
  # it starts with a vowel) This is obviously flawed in the general
  # sense as may labels have punctuation at the start and this method
  # does not translate punctuation to English words. Also, if a vowel is
  # pronounced as a consonant, the article should not be "an".
  #
  def article s
    article_for_letter(first_letter_of(s))
  end

  private

  def first_letter_of(string)
    char = string[0,1]
    if SKIPPED_CHARACTERS.include? char
      char = string[1,1]
    end

    if char == ""
      raise Puppet::DevError, _("<%{string}> does not appear to contain a word") % { string: string }
    end

    char
  end

  def article_for_letter(letter)
    downcased = letter.downcase
    if VOWELS.include? downcased
      AN
    else
      A
    end
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit