Sha256: 804d675db841a3b08c93b34766e269bd5e77960634bfae7ae862af5775428f6e

Contents?: true

Size: 530 Bytes

Versions: 13

Compression:

Stored size: 530 Bytes

Contents

module SoberSwag
  module Nodes
    ##
    # Compiler node to represent an enum value.
    # Enums are special enough to have their own node.
    class Enum < Base
      def initialize(values)
        @values = values
      end

      attr_reader :values

      def map(&block)
        self.class.new(@values.map(&block))
      end

      def deconstruct
        [values]
      end

      def deconstruct_keys(_keys)
        { values: values }
      end

      def cata(&block)
        block.call(dup)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sober_swag-0.14.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.13.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.12.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.11.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.10.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.9.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.8.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.7.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.6.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.5.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.4.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.3.0 lib/sober_swag/nodes/enum.rb
sober_swag-0.2.0 lib/sober_swag/nodes/enum.rb