barby 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -208,7 +208,7 @@ module Barby
208
208
  #character set, an extra will be created.
209
209
  def data=(data)
210
210
  data, *extra = data.split(/([#{CODEA+CODEB+CODEC}])/n)
211
- @data = data
211
+ @data = data || ''
212
212
  self.extra = extra.join unless extra.empty?
213
213
  end
214
214
 
@@ -226,9 +226,8 @@ module Barby
226
226
  #"change character set" symbol. The string may contain several character
227
227
  #sets, in which case the extra will itself have an extra.
228
228
  def extra=(extra)
229
- raise ArgumentError, "Extra must begin with \\301, \\302 or \\303" unless extra =~ /^[#{CODEA+CODEB+CODEC}]/n
230
- type = extra[/([#{CODEA+CODEB+CODEC}])/n, 1]
231
- data = extra[/[#{CODEA+CODEB+CODEC}](.*)/n, 1]
229
+ raise ArgumentError, "Extra must begin with \\305, \\306 or \\307" unless extra =~ /^[#{CODEA+CODEB+CODEC}]/n
230
+ type, data = extra[0,1], extra[1..-1]
232
231
  @extra = class_for(type).new(data)
233
232
  end
234
233
 
@@ -359,9 +358,10 @@ module Barby
359
358
  end
360
359
 
361
360
  #Is the data in this barcode valid? Does a lookup of every character
362
- #and checks if it exists in the character set.
361
+ #and checks if it exists in the character set. An empty data string
362
+ #will also be reported as invalid.
363
363
  def valid?
364
- characters.all?{|c| values.include?(c) }
364
+ characters.any? && characters.all?{|c| values.include?(c) }
365
365
  end
366
366
 
367
367
  def values
@@ -2,7 +2,7 @@ module Barby #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tore Darell
@@ -9,7 +9,7 @@ autorequire: barby
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-22 00:00:00 +01:00
12
+ date: 2009-11-26 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15