Module: RoboEd

Defined in:
lib/robo_ed.rb,
lib/robo_ed/version.rb

Constant Summary collapse

ENDPOINT =
'http://www.ed.conpet.gov.br/mod_perl/bot_gateway.cgi?server=0.0.0.0%3A8085&charset_post=utf-8&charset=utf-8&pure=1&js=0&tst=1&msg='
TRUE_VALUES =
[true, 1, '1', 't', 'T', 'true', 'TRUE']
VERSION =
'1.1.2'
@@strip_tags =
false

Class Method Summary collapse

Class Method Details

.ask(question) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/robo_ed.rb', line 22

def self.ask question
  question = question.to_s
  raise 'Question cannot be blank!' if question.empty?

  request = open(ENDPOINT + URI.encode(question))

  answer = request.read.strip
  answer = answer.gsub(/<[^>]*>/, '') if self.strip_tags

  return answer
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (RoboEd)

    the object that the method was called on



18
19
20
# File 'lib/robo_ed.rb', line 18

def self.setup(&block)
  yield self
end

.strip_tagsObject



10
11
12
# File 'lib/robo_ed.rb', line 10

def self.strip_tags
  @@strip_tags
end

.strip_tags=(option) ⇒ Object



14
15
16
# File 'lib/robo_ed.rb', line 14

def self.strip_tags= option
  @@strip_tags = TRUE_VALUES.include?(option)
end