Sha256: 8d685145e4341eb460ffbf51bc31d7aa64aee5c1b37f54b5c777a90b28d3738a
Contents?: true
Size: 750 Bytes
Versions: 1
Compression:
Stored size: 750 Bytes
Contents
# frozen_string_literal: true module Gamefic # A decomposition of a text-based command into its verb and arguments. # # Commands are typically derived from tokenization against syntaxes. # class Command # @return [Symbol] attr_reader :verb # @return [Array<String>] attr_reader :arguments def initialize verb, arguments @verb = verb @arguments = arguments end # Compare two syntaxes for the purpose of ordering them by relevance while # dispatching. # def compare other if verb == other.verb other.arguments.compact.length <=> arguments.compact.length else (other.verb ? 1 : 0) <=> (verb ? 1 : 0) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gamefic-3.0.0 | lib/gamefic/command.rb |