Sha256: 4afbcd67160558916dd4fa7a20258e124703accdbb8a6484e57a5595b26d0bb9

Contents?: true

Size: 917 Bytes

Versions: 4

Compression:

Stored size: 917 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 = RootObject.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.22 lib/cayuga/tools/symbol.rb
cayuga-0.0.21 lib/cayuga/tools/symbol.rb
cayuga-0.0.20 lib/cayuga/tools/symbol.rb
cayuga-0.0.19 lib/cayuga/tools/symbol.rb