Sha256: ea9b7ee61eeb05b187a24484e8f8f62752b4565c73e004edc21917928945a038
Contents?: true
Size: 793 Bytes
Versions: 1
Compression:
Stored size: 793 Bytes
Contents
module SoberSwag module Nodes ## # A # # It's cool I promise. class Binary < Base def initialize(lhs, rhs) @lhs = lhs @rhs = rhs end attr_reader :lhs, :rhs ## # Map the root values of the node. # This just calls map on the lhs and the rhs def map(&block) self.class.new( lhs.map(&block), rhs.map(&block) ) end def deconstruct [lhs, rhs] end def deconstruct_keys(keys) { lhs: lhs, rhs: rhs } end ## # Perform a catamorphism on this node. def cata(&block) block.call( self.class.new( lhs.cata(&block), rhs.cata(&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/binary.rb |