Skip to content

Commit

Permalink
rename: Core::Value to Core::Stack
Browse files Browse the repository at this point in the history
  • Loading branch information
thadeu committed Dec 16, 2024
1 parent 721c0f6 commit 2e11ce0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/zx/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module Core
require_relative 'core/and_then'
require_relative 'core/caller'
require_relative 'core/match'
require_relative 'core/value'
require_relative 'core/stack'
end
2 changes: 1 addition & 1 deletion lib/zx/core/and_then.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(result)
end

def spawn!(&block)
lastly = Core::Value.last(result)
lastly = Core::Stack.last(result)

success = result.success?
type = result.type
Expand Down
12 changes: 6 additions & 6 deletions lib/zx/core/value.rb → lib/zx/core/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Zx
module Core
class Value
class Stack
def self.first(result)
new.first(result)
end
Expand All @@ -15,25 +15,25 @@ def self.unwrap!(object)
new.unwrap!(object)
end

def self.stack(object)
def self.nodes(object)
new.stack(object, [])
end

def stack(object, list = [])
def nodes(object, list = [])
if need_recursion? object
list << object
stack(object.value, list)
nodes(object.value, list)
end

Array(list).flatten
end

def first(object)
Array(stack(object)).flatten.first
Array(nodes(object)).flatten.first
end

def last(object)
Array(stack(object)).flatten.last
Array(nodes(object)).flatten.last
end

def unwrap!(object)
Expand Down
4 changes: 2 additions & 2 deletions lib/zx/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def unwrap
end

def last
Core::Value.last(self) || self
Core::Stack.last(self) || self
end

def first
Core::Value.first(self) || self
Core::Stack.first(self) || self
end

def inspect
Expand Down

0 comments on commit 2e11ce0

Please sign in to comment.