Sha256: 71b5bd4e598e5f7d4eb5c8cec964cb6cb459d441619f7197e48d2f2625fbef12

Contents?: true

Size: 831 Bytes

Versions: 4

Compression:

Stored size: 831 Bytes

Contents

# frozen_string_literal: true

module Lino
  module Model
    class Flag
      attr_reader :flag,
                  :placement

      def initialize(flag, opts = {})
        opts = with_defaults(opts)
        @flag = flag
        @placement = opts[:placement]
      end

      def string
        flag
      end
      alias to_s string

      def array
        [flag]
      end
      alias to_a string

      def ==(other)
        self.class == other.class &&
          state == other.state
      end
      alias eql? ==

      def hash
        [self.class, state].hash
      end

      protected

      def state
        [
          @flag,
          @placement
        ]
      end

      private

      def with_defaults(opts)
        {
          placement: opts[:placement] || :after_command
        }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lino-3.2.0.pre.9 lib/lino/model/flag.rb
lino-3.2.0.pre.8 lib/lino/model/flag.rb
lino-3.2.0.pre.7 lib/lino/model/flag.rb
lino-3.2.0.pre.6 lib/lino/model/flag.rb