Skip to content

Commit

Permalink
Remove 'kind_of' method. It was inconsistent and caused some strange …
Browse files Browse the repository at this point in the history
…problems. Fixes #144 (#150)
  • Loading branch information
olbrich authored Dec 30, 2016
1 parent a04590c commit 2e0cced
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source 'https://rubygems.org'

ruby RUBY_VERSION

group :development do
gem 'bundler', '~> 1.0'
gem 'guard-rspec'
Expand Down
9 changes: 0 additions & 9 deletions lib/ruby_units/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,6 @@ def self.use_definition(definition)
# @return [String]
attr_accessor :unit_name

# needed to make complex units play nice -- otherwise not detected as a complex_generic
# @param [Class]
# @return [Boolean]
def kind_of?(klass)
# rubocop:disable Style/ClassCheck
scalar.kind_of?(klass)
# rubocop:enable Style/ClassCheck
end

# Used to copy one unit to another
# @param [Unit] from Unit to copy definition from
# @return [Unit]
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby_units/complex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
describe 'Complex Unit' do
subject { Complex(1.0, -1.0).to_unit }

it { is_expected.to be_instance_of Unit }
it(:scalar) { is_expected.to be_kind_of Complex }
it { is_expected.to be_a Unit }
it { expect(subject.scalar).to be_a Complex }

it { is_expected.to eq('1-1i'.to_unit) }
it { is_expected.to be === '1-1i'.to_unit }
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby_units/math_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe '#sqrt' do
specify { expect(Math.sqrt(RubyUnits::Unit.new('1 mm^6'))).to eq(RubyUnits::Unit.new('1 mm^3')) }
specify { expect(Math.sqrt(4)).to eq(2) }
specify { expect(Math.sqrt(RubyUnits::Unit.new('-9 mm^2'))).to be_kind_of(Complex) }
specify { expect(Math.sqrt(RubyUnits::Unit.new('-9 mm^2')).scalar).to be_kind_of(Complex) }
end

describe '#cbrt' do
Expand Down

0 comments on commit 2e0cced

Please sign in to comment.