Class: Rae

Inherits:
Object
  • Object
show all
Defined in:
lib/rae.rb

Instance Method Summary collapse

Constructor Details

#initializeRae

Returns a new instance of Rae.



8
9
# File 'lib/rae.rb', line 8

def initialize
end

Instance Method Details

#search(word, bus = 3) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rae.rb', line 11

def search(word, bus = 3)
  agent = Mechanize.new
  agent.user_agent_alias = 'Mac Safari'
  page = agent.get 'http://buscon.rae.es/draeI/html/cabecera.htm'

  form = page.forms.first

  form['TIPO_BUS'] = bus
  form['LEMA'] = word

  page = agent.submit(form, form.buttons.first)

  parse_page(page, word)
end