basecustom 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,10 @@
1
1
  class BaseCustom
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
4
4
 
5
+ # Version 0.1.4
6
+ # * My father suggested delimiter splitting on String initialization made more sense.
7
+ # * Test-Unit assertions fixed/updated.
5
8
  # Version 0.1.3
6
9
  # * Fixed multicharacter numbering units
7
10
  # * Added delimiter for multicharacter numbering units
data/lib/basecustom.rb CHANGED
@@ -8,10 +8,7 @@ require 'basecustom/version'
8
8
  class BaseCustom
9
9
  def initialize(array_in, delim = '')
10
10
  if array_in.is_a?(String)
11
- if not delim.empty?
12
- raise "You must use an Array when defining with a delimiter."
13
- end
14
- array_in = array_in.split('')
11
+ array_in = array_in.split(delim)
15
12
  end
16
13
  if not array_in.is_a?(Array)
17
14
  raise "Invalid type! Please provide a String or an Array."
data/test/test_bc.rb CHANGED
@@ -31,7 +31,6 @@ class TestBaseCustom < Test::Unit::TestCase
31
31
  assert_raise RuntimeError, LoadError do base2.base('abc'); end
32
32
  assert_raise RuntimeError, LoadError do base2.base(4.5); end
33
33
  assert_raise RuntimeError, LoadError do baseFail = BaseCustom.new(%w[:a :b :c]); end
34
- assert_raise RuntimeError, LoadError do baseFail = BaseCustom.new(":a:b:c", ":"); end
35
34
  assert_raise RuntimeError, LoadError do baseFail = BaseCustom.new(0..9); end
36
35
  assert_raise RuntimeError, LoadError do baseFail = BaseCustom.new(['0','1',2]); end
37
36
  end
@@ -44,13 +43,19 @@ class TestBaseCustom < Test::Unit::TestCase
44
43
 
45
44
  def test_delim_music
46
45
  baseMusic = BaseCustom.new( %w[A A# B C C# D D# E F F# G G#], ' ' )
47
- baseMusic.base( (Math::PI * 100000000).to_i ) == "F F# B D# D A# D# F# "
48
- baseMusic.base( "F F# B D# D A# D# F# " ) == (Math::PI * 100000000).to_i
46
+ assert baseMusic.base( (Math::PI * 100000000).to_i ) == "F F# B D# D A# D# F# "
47
+ assert baseMusic.base( "F F# B D# D A# D# F# " ) == (Math::PI * 100000000).to_i
49
48
  end
50
49
 
51
50
  def test_multi_with_delim
52
51
  baseMND = BaseCustom.new(%w(aa bb cc), ':')
53
- baseMND.base(12) == "bb:bb:aa:"
54
- baseMND.base("bb:bb:aa:") == 12
52
+ assert baseMND.base(12) == "bb:bb:aa:"
53
+ assert baseMND.base("bb:bb:aa:") == 12
54
+ end
55
+
56
+ def test_multi_in_string_with_delim
57
+ baseMND = BaseCustom.new("aa:bb:cc", ':')
58
+ assert baseMND.base(12) == "bb:bb:aa:"
59
+ assert baseMND.base("bb:bb:aa:") == 12
55
60
  end
56
61
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basecustom
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel P. Clark / 6ftDan(TM)