barby 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/barby/barcode/code_128.rb +6 -6
- data/lib/barby/version.rb +1 -1
- metadata +2 -2
@@ -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 \\
|
230
|
-
type = extra[
|
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
|
data/lib/barby/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2009-11-26 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|