Sha256: 1a1ee2f27d6c92b777e56aeeca506d43f0799b91c92714762a359845866a9ca7
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Dendroid module Syntax # Abstract class for grammar symbols. # A grammar symbol is an element that appears in grammar rules. class GrmSymbol # @return [String] The name of the grammar symbol attr_reader :name # Constructor. # aSymbolName [String] The name of the grammar symbol. def initialize(symbolName) @name = valid_name(symbolName) end # The String representation of the grammar symbol # @return [String] def to_s name.to_s end # Equality testing (based on symbol name) # @return [Boolean] def ==(other) name == other.name end private def valid_name(symbolName) if symbolName.is_a?(String) stripped = symbolName.strip if stripped.empty? err_msg = 'A symbol name cannot be empty.' raise StandardError, err_msg end stripped.to_sym else symbolName end end end # class end # module end # module
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dendroid-0.0.1 | lib/dendroid/syntax/grm_symbol.rb |
dendroid-0.0.0 | lib/dendroid/syntax/grm_symbol.rb |