alc-cmd 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/alc-cmd/cli.rb +0 -14
- data/lib/alc-cmd/eijiro.rb +7 -7
- data/lib/alc-cmd/version.rb +1 -1
- metadata +1 -1
data/lib/alc-cmd/cli.rb
CHANGED
@@ -8,21 +8,7 @@ module Alc; module Cmd
|
|
8
8
|
|
9
9
|
desc "s [WORD1 WORD2]", "serach words"
|
10
10
|
def s(*words)
|
11
|
-
|
12
11
|
Eijiro.new.search(words)
|
13
|
-
#result = ""
|
14
|
-
#eijiro = Eijiro.new(words)
|
15
|
-
|
16
|
-
#eijiro.get_search_assistances.each do |assistance|
|
17
|
-
# result << set_color(assistance, :green) + "\n"
|
18
|
-
#end
|
19
|
-
|
20
|
-
#meanings = eijiro.get_meanings
|
21
|
-
#eijiro.get_titles.each_with_index do |title, index|
|
22
|
-
# result << set_color(title, :yellow) + "\n"
|
23
|
-
# result << set_color(meanings[index]) + "\n"
|
24
|
-
#end
|
25
|
-
#result
|
26
12
|
end
|
27
13
|
|
28
14
|
end
|
data/lib/alc-cmd/eijiro.rb
CHANGED
@@ -7,11 +7,11 @@ module Alc; module Cmd
|
|
7
7
|
BASE_URI = "http://eow.alc.co.jp/"
|
8
8
|
CHAR_CODE = "/UTF-8/"
|
9
9
|
|
10
|
-
def initialize()
|
10
|
+
def initialize() #:nodoc:
|
11
11
|
@agent = Mechanize.new
|
12
12
|
end
|
13
13
|
|
14
|
-
def search(words)
|
14
|
+
def search(words) #:nodoc:
|
15
15
|
@agent.get(make_uri_from_words(words))
|
16
16
|
@words = words
|
17
17
|
result = ""
|
@@ -27,15 +27,15 @@ module Alc; module Cmd
|
|
27
27
|
result
|
28
28
|
end
|
29
29
|
|
30
|
-
def make_uri_from_words(words)
|
30
|
+
def make_uri_from_words(words) #:nodoc:
|
31
31
|
return BASE_URI + make_query_from_words(words) + CHAR_CODE
|
32
32
|
end
|
33
33
|
|
34
|
-
def make_query_from_words(words)
|
34
|
+
def make_query_from_words(words) #:nodoc:
|
35
35
|
return words.map { |param| URI.encode(param) }.join('+')
|
36
36
|
end
|
37
37
|
|
38
|
-
def get_search_assistances
|
38
|
+
def get_search_assistances #:nodoc:
|
39
39
|
assistances = []
|
40
40
|
@agent.page.search('div.sas strong').map do |h|
|
41
41
|
assistances << h.inner_text.chomp("\t\t\t\t\t\t")
|
@@ -43,13 +43,13 @@ module Alc; module Cmd
|
|
43
43
|
assistances
|
44
44
|
end
|
45
45
|
|
46
|
-
def get_titles
|
46
|
+
def get_titles #:nodoc:
|
47
47
|
return @agent.page.search('li span.midashi').map do |midashi|
|
48
48
|
inner_text = midashi.inner_text
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def get_meanings
|
52
|
+
def get_meanings #:nodoc:
|
53
53
|
meanings = Array.new
|
54
54
|
@agent.page.search('li div').each do |div|
|
55
55
|
lis = div.search('li')
|
data/lib/alc-cmd/version.rb
CHANGED