Sha256: 50ab370036530b0007ab41faaf658b1200ab78b8c774533fdbd89690844f2c1e

Contents?: true

Size: 903 Bytes

Versions: 7

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

require 'hamster'

require_relative '../model'
require_relative 'mixins/options'
require_relative 'mixins/appliables'

module Lino
  module Builders
    class Subcommand
      include Mixins::Options
      include Mixins::Appliables

      class << self
        def for_subcommand(subcommand)
          Builders::Subcommand.new(subcommand:)
        end
      end

      def initialize(state)
        @subcommand = state[:subcommand]
        @options = Hamster::Vector.new(state[:options] || [])
      end

      def build
        Model::Subcommand.new(
          @subcommand,
          options: build_options
        )
      end

      private

      def with(replacements)
        Builders::Subcommand.new(state.merge(replacements))
      end

      def state
        {
          subcommand: @subcommand,
          options: @options
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lino-4.0.0 lib/lino/builders/subcommand.rb
lino-4.0.0.pre.2 lib/lino/builders/subcommand.rb
lino-3.2.0.pre.10 lib/lino/builders/subcommand.rb
lino-3.2.0.pre.9 lib/lino/builders/subcommand.rb
lino-3.2.0.pre.8 lib/lino/builders/subcommand.rb
lino-3.2.0.pre.7 lib/lino/builders/subcommand.rb
lino-3.2.0.pre.6 lib/lino/builders/subcommand.rb