Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/irb/command/pushws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ module Command
class Workspaces < Base
category "Workspace"
description "Show workspaces."
MAX_WORKSPACE_INSPECT_LENGTH = 20

def execute(_arg)
inspection_resuls = irb_context.instance_variable_get(:@workspace_stack).map do |ws|
inspection_results = irb_context.instance_variable_get(:@workspace_stack).map do |ws|
truncated_inspect(ws.main)
end

puts "[" + inspection_resuls.join(", ") + "]"
puts "[" + inspection_results.join(", ") + "]"
end

private

def truncated_inspect(obj)
obj_inspection = obj.inspect

if obj_inspection.size > 20
if obj_inspection.size > MAX_WORKSPACE_INSPECT_LENGTH
obj_inspection = obj_inspection[0, 19] + "...>"
end

Expand Down