crown 0.0.7 → 0.0.8
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/ChangeLog +4 -0
- data/VERSION +1 -1
- data/crown.gemspec +1 -1
- data/lib/crown.rb +1 -1
- data/lib/crown/amazon.rb +23 -4
- metadata +3 -3
data/ChangeLog
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/crown.gemspec
CHANGED
data/lib/crown.rb
CHANGED
data/lib/crown/amazon.rb
CHANGED
@@ -100,10 +100,11 @@ module Crown
|
|
100
100
|
#
|
101
101
|
# --------------------------------------------------------------- #
|
102
102
|
def get_asin(path, query)
|
103
|
-
path
|
104
|
-
|
105
|
-
|
106
|
-
|
103
|
+
if (path != nil)
|
104
|
+
path.scan(/[B0123489][A-Z0-9]{9}/) { |asin|
|
105
|
+
return asin if (asin[0].chr == 'B' || check_digit(asin))
|
106
|
+
}
|
107
|
+
end
|
107
108
|
|
108
109
|
if (query != nil)
|
109
110
|
asin = query.match(/[B0123489][A-Z0-9]{9}/)
|
@@ -112,6 +113,24 @@ module Crown
|
|
112
113
|
|
113
114
|
return nil
|
114
115
|
end
|
116
|
+
|
117
|
+
# --------------------------------------------------------------- #
|
118
|
+
#
|
119
|
+
# check_digit
|
120
|
+
#
|
121
|
+
# ISBN-10 のチェックディジット計算して,有効な ISBN-10 の値か
|
122
|
+
# どうか判定する.
|
123
|
+
#
|
124
|
+
# --------------------------------------------------------------- #
|
125
|
+
def check_digit(asin)
|
126
|
+
sum = 0
|
127
|
+
(0..8).each { |i|
|
128
|
+
sum += (10 - i) * asin[i].chr.to_i
|
129
|
+
}
|
130
|
+
check = 11 - (sum % 11)
|
131
|
+
check = (check < 10) ? check.to_s : ((check == 10) ? 'X' : '0')
|
132
|
+
return check == asin[9].chr
|
133
|
+
end
|
115
134
|
end
|
116
135
|
|
117
136
|
# ------------------------------------------------------------------- #
|
metadata
CHANGED