Sha256: 24551bda06de41f55469a0949cfe1cc1b7a79fbc942f1e7b952ee43fbb62648b

Contents?: true

Size: 465 Bytes

Versions: 1

Compression:

Stored size: 465 Bytes

Contents

module SoberSwag
  module Nodes
    ##
    # Root node of the tree
    class Primitive < Base
      def initialize(value)
        @value = value
      end

      attr_reader :value

      def map(&block)
        self.class.new(block.call(value))
      end

      def deconstruct
        [value]
      end

      def deconstruct_keys(_)
        { value: value }
      end

      def cata(&block)
        block.call(self.class.new(value))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sober_swag-0.1.0 lib/sober_swag/nodes/primitive.rb