Class: Ciba
- Inherits:
-
Object
- Object
- Ciba
- Defined in:
- lib/ciba.rb
Instance Method Summary collapse
- #examples ⇒ Object
-
#initialize(key = '36CC7638D81785E7006BB5B29DBA1FEF') ⇒ Ciba
constructor
A new instance of Ciba.
- #pos ⇒ Object
- #set_model(word) ⇒ Object
- #sound ⇒ Object
- #symbol ⇒ Object
- #word ⇒ Object
Constructor Details
#initialize(key = '36CC7638D81785E7006BB5B29DBA1FEF') ⇒ Ciba
Returns a new instance of Ciba.
4 5 6 |
# File 'lib/ciba.rb', line 4 def initialize(key='36CC7638D81785E7006BB5B29DBA1FEF') @key=key end |
Instance Method Details
#examples ⇒ Object
49 50 51 |
# File 'lib/ciba.rb', line 49 def examples @examples end |
#pos ⇒ Object
45 46 47 |
# File 'lib/ciba.rb', line 45 def pos @pos end |
#set_model(word) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ciba.rb', line 8 def set_model(word) @word=word @url = "http://dict-co.iciba.com/api/dictionary.php?w=#{@word}&key=#{@key}" xml="" open(@url) do |http| xml<<http.read end rss = Hash.from_xml(xml) @symbol = rss['dict']['ps'][0] @sound = rss['dict']['pron'][0] @pos=[] begin rss['dict']['pos'].each_with_index { |pos, index| @pos<<(pos+' '+rss['dict']['acceptation'][index]) } rescue @pos=rss['dict']['pos']+' '+rss['dict']['acceptation'] end @examples=[] begin rss['dict']['sent'].each { |sent| @examples<<sent['orig']+"\n"+sent['trans']+"\n" } rescue @examples=rss['dict']['sent']['orig']+"\n"+rss['dict']['sent']['trans']+"\n" end end |
#sound ⇒ Object
41 42 43 |
# File 'lib/ciba.rb', line 41 def sound @sound end |
#symbol ⇒ Object
37 38 39 |
# File 'lib/ciba.rb', line 37 def symbol @symbol end |
#word ⇒ Object
53 54 55 |
# File 'lib/ciba.rb', line 53 def word @word end |