Sha256: a6d7ef3b6334e6b5d4af0e45f32f2eb6d1a71f0e140f5128019367c040db002f

Contents?: true

Size: 563 Bytes

Versions: 4

Compression:

Stored size: 563 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".to_sym
      end

      private

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby_git_crypt-0.1.0.pre.5 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0.pre.4 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0.pre.3 lib/ruby_git_crypt/options/name.rb
ruby_git_crypt-0.1.0.pre.2 lib/ruby_git_crypt/options/name.rb