Sha256: 888dcef76770a2325e16fad663fec44fa9284647ec8cd3a15f874bd929de59b1

Contents?: true

Size: 841 Bytes

Versions: 8

Compression:

Stored size: 841 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.to_s
      end
      alias to_s string

      def array
        [flag.to_s]
      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

8 entries across 8 versions & 1 rubygems

Version Path
lino-4.2.0.pre.2 lib/lino/model/flag.rb
lino-4.2.0.pre.1 lib/lino/model/flag.rb
lino-4.1.0 lib/lino/model/flag.rb
lino-4.1.0.pre.2 lib/lino/model/flag.rb
lino-4.1.0.pre.1 lib/lino/model/flag.rb
lino-4.0.0 lib/lino/model/flag.rb
lino-4.0.0.pre.2 lib/lino/model/flag.rb
lino-3.2.0.pre.10 lib/lino/model/flag.rb