Sha256: 7d6e933b31253cc18605ddbbdac5db38a8f7d4e6d0b1ca7cb7637675d6feded1

Contents?: true

Size: 585 Bytes

Versions: 63

Compression:

Stored size: 585 Bytes

Contents

# frozen_string_literal: true

require 'immutable-struct'

module RubyTerraform
  module Options
    class Name < ImmutableStruct.new(:name)
      def initialize(name)
        super(name: name.to_s)
      end

      def name
        "-#{without_prefix}"
      end

      alias to_s name

      def as_singular_key
        snake_case.to_sym
      end

      def as_plural_key
        "#{snake_case}s".to_sym
      end

      private

      def without_prefix
        @name.sub(/^-+/, '')
      end

      def snake_case
        without_prefix.gsub('-', '_')
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
ruby-terraform-0.65.0.pre.14 lib/ruby_terraform/options/name.rb
ruby-terraform-0.65.0.pre.13 lib/ruby_terraform/options/name.rb
ruby-terraform-0.65.0.pre.12 lib/ruby_terraform/options/name.rb