Sha256: e327c048629ba458d9ff42877a0ed02450b16e1f85265a5714412a79e18a2559

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'

require_relative './option_spec_item'

module ArticleFixtureGen
  module Exe
    module Trollop
      # Encapsulate configuration of a Trollop command-line option
      class OptionSpec
        extend Forwardable

        def initialize(*key_and_desc, **options)
          @item = OptionSpecItem.new key: key_and_desc[0],
                                     desc: key_and_desc[1], options: options
          # freeze # Cannot freeze data passed to `Trollop.opt`.
          #          WTFometer at 11.
          self
        end

        def add_option(context)
          context.opt key, desc, options
        end

        def_delegators :@item, :desc, :key, :options
      end # class ArticleFixtureGen::Exe::Trollop::OptionSpec
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
article_fixture_gen-0.1.2 lib/article_fixture_gen/exe/option_parser/trollop/option_spec.rb
article_fixture_gen-0.1.1 lib/article_fixture_gen/exe/option_parser/trollop/option_spec.rb