Sha256: 50e9e87d27fc266bf8f01d707f01e8a56ce50190ab966c2cb13d6d8ba96151af
Contents?: true
Size: 690 Bytes
Versions: 18
Compression:
Stored size: 690 Bytes
Contents
module SoberSwag module Nodes ## # Base class for nodes that contain arrays of other nodes. # This is very different from an attribute representing a node which *is* an array of some element type!! class Array < Base def initialize(elements) @elements = elements end attr_reader :elements def map(&block) self.class.new(elements.map { |elem| elem.map(&block) }) end def cata(&block) block.call(self.class.new(elements.map { |elem| elem.cata(&block) })) end def deconstruct @elements end def deconstruct_keys(_keys) { elements: @elements } end end end end
Version data entries
18 entries across 18 versions & 1 rubygems