Skip to content

Commit

Permalink
Merge pull request #1723 from OpenC3/inspect
Browse files Browse the repository at this point in the history
Remove inpect override in array and hash
  • Loading branch information
ryanmelt authored Nov 28, 2024
2 parents 220bed4 + f2f6bdd commit 9051e2b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 101 deletions.
1 change: 0 additions & 1 deletion openc3/lib/openc3/core_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
require 'openc3/core_ext/exception'
require 'openc3/core_ext/faraday'
require 'openc3/core_ext/file'
require 'openc3/core_ext/hash'
require 'openc3/core_ext/io'
require 'openc3/core_ext/kernel'
require 'openc3/core_ext/math'
Expand Down
16 changes: 0 additions & 16 deletions openc3/lib/openc3/core_ext/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@

# OpenC3 specific additions to the Ruby Array class
class Array
# Redefine inspect to only print for small numbers of
# items. Prevents exceptions taking forever to be raise with
# large objects. See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/105145
alias old_inspect inspect

# @param max_elements [Integer] The maximum number of elements in the array to
# print out before simply displaying the array class and object id
# @return [String] String representation of the array
def inspect(max_elements = 10)
if self.length <= max_elements
old_inspect()
else
'#<' + self.class.to_s + ':' + self.object_id.to_s + '>'
end
end

# @return [Array] Cloned array after all elements called to_f
def clone_to_f
new_array = self.class.new(0)
Expand Down
40 changes: 0 additions & 40 deletions openc3/lib/openc3/core_ext/hash.rb

This file was deleted.

11 changes: 2 additions & 9 deletions openc3/spec/core_ext/array_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,16 @@
# GNU Affero General Public License for more details.

# Modified by OpenC3, Inc.
# All changes Copyright 2022, OpenC3, Inc.
# All changes Copyright 2024, OpenC3, Inc.
# All Rights Reserved
#
# This file may also be used under the terms of a commercial license
# This file may also be used under the terms of a commercial license
# if purchased from OpenC3, Inc.

require 'spec_helper'
require 'openc3/core_ext/array'

describe Array do
describe "inspect" do
it "limits the number of items to 10" do
expect(Array.new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).inspect).to eql "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
expect(Array.new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).inspect).to match(/#<Array:\d+>/)
end
end

describe "clone_to_f" do
it "clones the array and convert all the values to floats" do
expect(Array.new([1, 2, 3, 4, 5]).clone_to_f).to eql [1.0, 2.0, 3.0, 4.0, 5.0]
Expand Down
35 changes: 0 additions & 35 deletions openc3/spec/core_ext/hash_spec.rb

This file was deleted.

0 comments on commit 9051e2b

Please sign in to comment.