Class: FaxFinder::Response

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

Constant Summary collapse

REGEXP_KEYS =
/([0-9A-F]+)\/([0-9A-F]+)$/
XPATH_STATE =
'//fax_entry/state'
XPATH_FAX_ENTRY_URL =
'//fax_entry/fax_entry_url'
XPATH_TRY_NUMBER =
'//fax_entry/try_number'
XPATH_MESSAGE =
'//response/message'
XPATH_SCHEDULE_MESSAGE =
'//fax_entry/schedule_message'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_doc) ⇒ Response

Returns a new instance of Response.



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fax_finder/response.rb', line 31

def initialize(_doc)
  @doc=_doc
  if self.doc
    @message=self.doc.xpath(XPATH_MESSAGE).text
    @state=self.doc.xpath(XPATH_STATE).text
    if @state != 'error'
      @fax_entry_url=self.doc.xpath(XPATH_FAX_ENTRY_URL).text
      @fax_key, @entry_key=self.extract_fax_and_entry_key(self.fax_entry_url)
      @try_number=self.doc.xpath(XPATH_TRY_NUMBER).text.to_i
      @schedule_message=self.doc.xpath(XPATH_SCHEDULE_MESSAGE).text
    end
  end
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



23
24
25
# File 'lib/fax_finder/response.rb', line 23

def doc
  @doc
end

#entry_keyObject (readonly)

Returns the value of attribute entry_key.



23
24
25
# File 'lib/fax_finder/response.rb', line 23

def entry_key
  @entry_key
end

#fax_entry_urlObject (readonly)

Returns the value of attribute fax_entry_url.



23
24
25
# File 'lib/fax_finder/response.rb', line 23

def fax_entry_url
  @fax_entry_url
end

#fax_keyObject (readonly)

Returns the value of attribute fax_key.



23
24
25
# File 'lib/fax_finder/response.rb', line 23

def fax_key
  @fax_key
end

#messageObject (readonly)

Returns the value of attribute message.



23
24
25
# File 'lib/fax_finder/response.rb', line 23

def message
  @message
end

#schedule_messageObject (readonly)

Returns the value of attribute schedule_message.



23
24
25
# File 'lib/fax_finder/response.rb', line 23

def schedule_message
  @schedule_message
end

#stateObject (readonly)

Returns the value of attribute state.



23
24
25
# File 'lib/fax_finder/response.rb', line 23

def state
  @state
end

#try_numberObject (readonly)

Returns the value of attribute try_number.



23
24
25
# File 'lib/fax_finder/response.rb', line 23

def try_number
  @try_number
end

Instance Method Details

#extract_fax_and_entry_key(_url) ⇒ Object



45
46
47
48
# File 'lib/fax_finder/response.rb', line 45

def extract_fax_and_entry_key(_url)
  match=REGEXP_KEYS.match(_url)
  match[1,2] if match
end