Sha256: fde0baf353d34b2c78db4e35b4615f87d0b16a37dff8fde4d3856debf9379ea9

Contents?: true

Size: 557 Bytes

Versions: 8

Compression:

Stored size: 557 Bytes

Contents

# frozen_string_literal: true

require 'immutable-struct'

module RubyGitCrypt
  module Options
    class Name < ImmutableStruct.new(:name, :prefix)
      attr_reader :name

      def initialize(name)
        super(name: name.to_s)
      end

      alias to_s name

      def as_singular_key
        snake_case.to_sym
      end

      def as_plural_key
        :"#{snake_case}s"
      end

      private

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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby_git_crypt-0.2.0.pre.2 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.2.0.pre.1 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0.pre.10 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0.pre.9 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0.pre.8 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0.pre.7 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0.pre.6 lib/ruby_git_crypt/options/name.rb