Sha256: e250ff4ab34496a0d521fdaec6bb6a4ada89dc468f7eca7d314b9bf440631a25

Contents?: true

Size: 527 Bytes

Versions: 2

Compression:

Stored size: 527 Bytes

Contents

# frozen_string_literal: true

module Clamp
  module Subcommand

    Definition = Struct.new(:name, :description, :subcommand_class) do

      def initialize(names, description, subcommand_class)
        @names = Array(names)
        @description = description
        @subcommand_class = subcommand_class
      end

      attr_reader :names, :description, :subcommand_class

      def is_called?(name)
        names.member?(name)
      end

      def help
        [names.join(", "), description]
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clamp-1.3.1 lib/clamp/subcommand/definition.rb
clamp-1.3.0 lib/clamp/subcommand/definition.rb