Sha256: 270041b981744b7aae4cc25bc8a73d21b02b844f6d390345ad147aad5400093c

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

module SoberSwag
  module Nodes
    ##
    # A List of the contained element types.
    #
    # Unlike {SoberSwag::Nodes::Array}, this actually models arrays.
    # The other one is a node that *is* an array in terms of what it contains.
    # Kinda confusing, but oh well.
    class List < Base
      def initialize(element)
        @element = element
      end

      attr_reader :element

      def deconstruct
        [element]
      end

      def deconstruct_keys(_)
        { element: element }
      end

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

      def map(&block)
        self.class.new(
          element.map(&block)
        )
      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/list.rb