class SoberSwag::Nodes::Binary
A binary node: has a left and right hand side. Basically a node of a binary tree.
Attributes
lhs[R]
@return [SoberSwag::Nodes::Base] the left-hand node
rhs[R]
@return [SoberSwag::Nodes::Base] the right-hand node
Public Class Methods
new(lhs, rhs)
click to toggle source
@param lhs [SoberSwag::Nodes::Base] the left-hand node. @param rhs [SoberSwag::Nodes::Base] the right-hand node.
# File lib/sober_swag/nodes/binary.rb, line 10 def initialize(lhs, rhs) @lhs = lhs @rhs = rhs end
Public Instance Methods
cata(&block)
click to toggle source
@see SoberSwag::Nodes::Base#cata
Maps over the LHS side first, then the RHS side, then the root.
# File lib/sober_swag/nodes/binary.rb, line 41 def cata(&block) block.call( self.class.new( lhs.cata(&block), rhs.cata(&block) ) ) end
deconstruct()
click to toggle source
Deconstructs into an array of `[lhs, rhs]`
@return [Array(SoberSwag::Nodes::Base
, SoberSwag::Nodes::Base
)]
# File lib/sober_swag/nodes/binary.rb, line 27 def deconstruct [lhs, rhs] end
deconstruct_keys(_keys)
click to toggle source
Deconstruct into a hash of attributes.
# File lib/sober_swag/nodes/binary.rb, line 33 def deconstruct_keys(_keys) { lhs: lhs, rhs: rhs } end
map(&block)
click to toggle source
@see SoberSwag::Nodes::Base#map
Maps over the LHS side first, then the RHS side, then the root.
# File lib/sober_swag/nodes/binary.rb, line 54 def map(&block) self.class.new( lhs.map(&block), rhs.map(&block) ) end