Sha256: 2a3b73a2d6a928692bb77e15999e41e90296668754e8f7343191cf8307fba80f

Contents?: true

Size: 762 Bytes

Versions: 18

Compression:

Stored size: 762 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

18 entries across 18 versions & 1 rubygems

Version Path
sober_swag-0.19.0 lib/sober_swag/nodes/list.rb
sober_swag-0.18.0 lib/sober_swag/nodes/list.rb
sober_swag-0.17.0 lib/sober_swag/nodes/list.rb
sober_swag-0.16.0 lib/sober_swag/nodes/list.rb
sober_swag-0.15.0 lib/sober_swag/nodes/list.rb
sober_swag-0.14.0 lib/sober_swag/nodes/list.rb
sober_swag-0.13.0 lib/sober_swag/nodes/list.rb
sober_swag-0.12.0 lib/sober_swag/nodes/list.rb
sober_swag-0.11.0 lib/sober_swag/nodes/list.rb
sober_swag-0.10.0 lib/sober_swag/nodes/list.rb
sober_swag-0.9.0 lib/sober_swag/nodes/list.rb
sober_swag-0.8.0 lib/sober_swag/nodes/list.rb
sober_swag-0.7.0 lib/sober_swag/nodes/list.rb
sober_swag-0.6.0 lib/sober_swag/nodes/list.rb
sober_swag-0.5.0 lib/sober_swag/nodes/list.rb
sober_swag-0.4.0 lib/sober_swag/nodes/list.rb
sober_swag-0.3.0 lib/sober_swag/nodes/list.rb
sober_swag-0.2.0 lib/sober_swag/nodes/list.rb