ciba 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/ciba.rb +57 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f570b4a6f8abded5c05c9a6748f63e8bc0d85438
|
4
|
+
data.tar.gz: ec120b554d1053dbf9a524020241959eba4cd081
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49b92bb11fbc0dfdd0153e6ee1e0e68014f0fb19f6d0d6092717f291d091c847e81c31be13a93d5723a78bb2901149e9373b880da65b4cdc7030b0c144b3028b
|
7
|
+
data.tar.gz: 5747fb04b9da21cf6dba371448851e987490dc26df853f70ca588b57a5ebaac243e17591632614f66282e694698428e91870bbfd066aafa53d4edfbd0afb5874
|
data/lib/ciba.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
class Ciba
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
def initialize(key='36CC7638D81785E7006BB5B29DBA1FEF')
|
5
|
+
@key=key
|
6
|
+
end
|
7
|
+
|
8
|
+
def set_model(word)
|
9
|
+
@word=word
|
10
|
+
@url = "http://dict-co.iciba.com/api/dictionary.php?w=#{@word}&key=#{@key}"
|
11
|
+
xml=""
|
12
|
+
open(@url) do |http|
|
13
|
+
xml<<http.read
|
14
|
+
end
|
15
|
+
rss = Hash.from_xml(xml)
|
16
|
+
@symbol = rss['dict']['ps'][0]
|
17
|
+
@sound = rss['dict']['pron'][0]
|
18
|
+
@pos=[]
|
19
|
+
begin
|
20
|
+
rss['dict']['pos'].each_with_index { |pos, index|
|
21
|
+
@pos<<(pos+' '+rss['dict']['acceptation'][index])
|
22
|
+
}
|
23
|
+
rescue
|
24
|
+
@pos=rss['dict']['pos']+' '+rss['dict']['acceptation']
|
25
|
+
end
|
26
|
+
|
27
|
+
@examples=[]
|
28
|
+
begin
|
29
|
+
rss['dict']['sent'].each { |sent|
|
30
|
+
@examples<<sent['orig']+"\n"+sent['trans']+"\n"
|
31
|
+
}
|
32
|
+
rescue
|
33
|
+
@examples=rss['dict']['sent']['orig']+"\n"+rss['dict']['sent']['trans']+"\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def symbol
|
38
|
+
@symbol
|
39
|
+
end
|
40
|
+
|
41
|
+
def sound
|
42
|
+
@sound
|
43
|
+
end
|
44
|
+
|
45
|
+
def pos
|
46
|
+
@pos
|
47
|
+
end
|
48
|
+
|
49
|
+
def examples
|
50
|
+
@examples
|
51
|
+
end
|
52
|
+
|
53
|
+
def word
|
54
|
+
@word
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ciba
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lean
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Ciba get Xml gem
|
14
|
+
email: leanv@sina.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/ciba.rb
|
20
|
+
homepage: http://rubygems.org/gems/
|
21
|
+
licenses:
|
22
|
+
- LEAN
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.1.11
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Aiciba!
|
44
|
+
test_files: []
|