jisho_helper 0.4.0 → 0.5.0
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.
- checksums.yaml +4 -4
- data/lib/jisho_helper.rb +2 -1
- data/lib/jisho_helper/jisho_tere.rb +17 -14
- data/lib/jisho_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fea0ceb321e08d8cd928530683115f813bcbf7f
|
4
|
+
data.tar.gz: 74bc18133e17c1a3f690dd8f88ac563787ec6e53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6f42b8341060149af383525b42c426b1a815de1928c803c5d8d9b078d641efec5b05d2a0be600b93187efbbcf546943d188bbbe2fee21d60370b3d1d0726843
|
7
|
+
data.tar.gz: c4060b22621d192f004903cd52dcec8288d6b5efdb334f10de7fbed97f798e3c47a01384f9c90d5ffcc4dc45e181e56ace8d6ad0d12367faabd184d2e78f021a
|
data/lib/jisho_helper.rb
CHANGED
@@ -11,9 +11,10 @@ class JishoHelper
|
|
11
11
|
require 'jisho_helper/jisho_tere'
|
12
12
|
|
13
13
|
def look_up keyword
|
14
|
+
japanese = true
|
14
15
|
japanese = false if URI.encode(keyword) == keyword
|
15
16
|
jisho = JishoHelper::JishoJisho.new(keyword)
|
16
|
-
tere = JishoHelper::JishoTere.new(keyword)
|
17
|
+
tere = JishoHelper::JishoTere.new(keyword, japanese)
|
17
18
|
breen = JishoHelper::JishoBreen.new(jisho.kanji)
|
18
19
|
result = JishoHelper::JishoResult.new(jisho.kana, jisho.kanji, tere.entry, breen.example1, breen.example2 ,keyword)
|
19
20
|
end
|
@@ -1,21 +1,24 @@
|
|
1
1
|
class JishoHelper::JishoTere
|
2
2
|
attr_reader :entry
|
3
3
|
|
4
|
-
def initialize keyword
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
unless id_doc.search('ItemID').empty?
|
9
|
-
id = id_doc.search('ItemID').first.inner_text
|
10
|
-
unless id.to_i == 0
|
11
|
-
word_url = tere_id_url id
|
12
|
-
word_doc = parse_xml word_url
|
13
|
-
word = word_doc.search('Body').children[1].text rescue nil
|
14
|
-
word.gsub!(/(\r\n|\r|\n|\t|\s)/, '')
|
15
|
-
@entry = word
|
16
|
-
end
|
4
|
+
def initialize keyword, japanese
|
5
|
+
if japanese
|
6
|
+
return @entry = 'N/A'
|
17
7
|
else
|
18
|
-
|
8
|
+
id_url = tere_url keyword
|
9
|
+
id_doc = parse_xml id_url
|
10
|
+
unless id_doc.search('ItemID').empty?
|
11
|
+
id = id_doc.search('ItemID').first.inner_text
|
12
|
+
unless id.to_i == 0
|
13
|
+
word_url = tere_id_url id
|
14
|
+
word_doc = parse_xml word_url
|
15
|
+
word = word_doc.search('Body').children[1].text rescue nil
|
16
|
+
word.gsub!(/(\r\n|\r|\n|\t|\s)/, '')
|
17
|
+
@entry = word
|
18
|
+
end
|
19
|
+
else
|
20
|
+
@entry = "N/A"
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
data/lib/jisho_helper/version.rb
CHANGED