Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove inpect override in array and hash #1723

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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.

Loading