Sha256: 637137c117a3b3756046683c7eb48b3e8fb3a58e418754d53b34b43d4ae05d49

Contents?: true

Size: 671 Bytes

Versions: 8

Compression:

Stored size: 671 Bytes

Contents

class Mustache
  module Utils
    class String
      def initialize string
        @string = string
      end

      def classify
        @string.split('/').map do |namespace|
          namespace.split(/[-_]/).map do |part|
            part[0] = part.chars.first.upcase
            part
          end.join
        end.join('::')
      end

      def underscore(view_namespace)
        @string
          .dup
          .split("#{view_namespace}::")
          .last
          .split('::')
          .map do |part|
            part[0] = part[0].downcase
            part.gsub(/[A-Z]/) { |s| "_" << s.downcase }
          end
          .join('/')
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
zine_brewer-1.5.0 vendor/bundle/ruby/2.7.0/gems/mustache-1.1.1/lib/mustache/utils.rb
zine_brewer-1.3.0 vendor/bundle/ruby/2.7.0/gems/mustache-1.1.1/lib/mustache/utils.rb
mustache-1.1.1 lib/mustache/utils.rb
mustache-1.1.0 lib/mustache/utils.rb
mustache-1.0.5 lib/mustache/utils.rb
mustache-1.0.3 lib/mustache/utils.rb
mustache-1.0.2 lib/mustache/utils.rb
mustache-1.0.1 lib/mustache/utils.rb