class Mingle::MingleIdentifier

Public Class Methods

as_format_name( id ) click to toggle source
# File lib/mingle.rb, line 1786
def self.as_format_name( id )

    sym = self.get( id ).to_sym

    if ID_STYLES.include?( sym )
        sym
    else
        raise "Unknown or invalid identifier format: #{id} (#{id.class})"
    end
end

Private Class Methods

impl_parse( s ) click to toggle source
# File lib/mingle.rb, line 1744
def self.impl_parse( s )
    MingleParser.consume_string( s ) { |p| p.expect_identifier }
end

Public Instance Methods

external_form() click to toggle source
# File lib/mingle.rb, line 1770
def external_form
    format( :lc_hyphenated )
end
Also aliased as: to_s
format( fmt ) click to toggle source
# File lib/mingle.rb, line 1749
def format( fmt )

    not_nil( fmt, :fmt )

    case fmt

        when ID_STYLE_LC_HYPHENATED then @parts.join( "-" )

        when ID_STYLE_LC_UNDERSCORE then @parts.join( "_" )

        when ID_STYLE_LC_CAMEL_CAPPED
            @parts[ 0 ] + 
            @parts[ 1 .. -1 ].map do 
                |t| t[ 0, 1 ].upcase + t[ 1 .. -1 ] 
            end.join

        else raise "Invalid format: #{fmt}"
    end
end
hash() click to toggle source
# File lib/mingle.rb, line 1782
def hash
    @parts.hash
end
to_s()
Alias for: external_form
to_sym() click to toggle source
# File lib/mingle.rb, line 1777
def to_sym
    format( :lc_underscore ).to_sym
end

Private Instance Methods

impl_initialize() click to toggle source
# File lib/mingle.rb, line 1737
def impl_initialize
    
    @parts.each_with_index do |part, idx|
        raise "Empty id part at index #{idx}" if part.size == 0
    end
end