Sha256: ce4bcc2dc15e8ceef716caea041189499011d0a5c3cb87545c10bc1c21194e70

Contents?: true

Size: 913 Bytes

Versions: 4

Compression:

Stored size: 913 Bytes

Contents

#
# Copyright (c) 2018 Patrick Thomas.  All rights reserved.
#
# noinspection RubyResolve
require 'facets/string/modulize'

module Cayuga
  module Tools
    # Cayuga Tools Symbol
    module Symbol
      def stringify
        to_s.gsub('___', '#').gsub('__', '::').tr('_', '-')
      end

      def symbolize
        self
      end

      def classify
        # noinspection RubyResolve
        klass = Object.const_get(to_s.modulize)
        raise NameError, "wrong class name '#{klass}'" unless klass.is_a?(Class)
        klass
      end

      def filenamify(extension = nil)
        # noinspection RubyResolve
        result = to_s
        unless extension.nil? || extension.empty?
          result += extension[0] == '.' ? '' : '.'
          result += extension.stringify
        end
        result
      end

    end
  end
end

Symbol.include(Cayuga::Tools::Symbol)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cayuga-0.0.18 lib/cayuga/tools/symbol.rb
cayuga-0.0.17 lib/cayuga/tools/symbol.rb
cayuga-0.0.16 lib/cayuga/tools/symbol.rb
cayuga-0.0.15 lib/cayuga/tools/symbol.rb