Sha256: 135c85581ddaee3ef0c8433471187dbd123e8bedefa90192957ee65950cc025a

Contents?: true

Size: 964 Bytes

Versions: 34

Compression:

Stored size: 964 Bytes

Contents

module CfnDsl
  module Plurals
    ##
    # Plural names for lists of content objects
    #
    
    @@plurals = { 
      "Metadata" => "Metadata", 
      "Property" => "Properties",
      "Policy" => "Policies",
      "PolicyDocument" => "PolicyDocument",
      "AssumeRolePolicyDocument" => "AssumeRolePolicyDocument",
      "SecurityGroupIngress" => "SecurityGroupIngress",
      "SecurityGroupEgress" => "SecurityGroupEgress",
      "DBSecurityGroupIngress" => "DBSecurityGroupIngress",
      "UpdatePolicy" => "UpdatePolicy",
      "CreationPolicy" => "CreationPolicy"
    }
    
    @@singles = {}
    @@plurals.each_pair { |key,val| @@singles[val] = key }

    def self.pluralize(name)
      name = name.to_s
      return @@plurals[name] if( @@plurals.has_key? name )
      return "#{name}s"
    end

    def self.singularize(name)
      name = name.to_s
      return @@singles[name] if( @@singles.has_key? name )
      return name[0..-2]
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
cfndsl-0.1.20 lib/cfndsl/Plurals.rb
cfndsl-0.1.19 lib/cfndsl/Plurals.rb
cfndsl-0.1.18 lib/cfndsl/Plurals.rb
cfndsl-0.1.17 lib/cfndsl/Plurals.rb
cfndsl-0.1.16 lib/cfndsl/Plurals.rb
cfndsl-0.1.15 lib/cfndsl/Plurals.rb
cfndsl-0.1.14 lib/cfndsl/Plurals.rb
cfndsl-0.1.13 lib/cfndsl/Plurals.rb
cfndsl-0.1.12 lib/cfndsl/Plurals.rb
cfndsl-0.1.11 lib/cfndsl/Plurals.rb
cfndsl-0.1.10 lib/cfndsl/Plurals.rb
cfndsl-0.1.9 lib/cfndsl/Plurals.rb
cfndsl-0.1.8 lib/cfndsl/Plurals.rb
cfndsl-0.1.7 lib/cfndsl/Plurals.rb