Sha256: ac4f59ba3abb872d1cac7beecdc707ec2d677563ee0a5cc0d25b9252da64b41f

Contents?: true

Size: 623 Bytes

Versions: 2

Compression:

Stored size: 623 Bytes

Contents

module RubyTerraform
  module Options
    class Name
      def initialize(name)
        @name = name
      end

      def without_prefix
        @name[0] == '-' ? @name[1..] : @name
      end

      def to_s
        "-#{without_prefix}"
      end

      def as_key
        snake_case.to_sym
      end

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

      def ==(other)
        to_s == other
      end

      def eql?(other)
        to_s == other
      end

      def hash
        to_s.hash
      end

      private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-terraform-0.65.0.pre.8 lib/ruby_terraform/options/name.rb
ruby-terraform-0.65.0.pre.7 lib/ruby_terraform/options/name.rb