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.



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

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.



25
26
27
# File 'lib/fax_finder/response.rb', line 25

def doc
  @doc
end

#entry_keyObject (readonly)

Returns the value of attribute entry_key.



25
26
27
# File 'lib/fax_finder/response.rb', line 25

def entry_key
  @entry_key
end

#fax_entry_urlObject (readonly)

Returns the value of attribute fax_entry_url.



25
26
27
# File 'lib/fax_finder/response.rb', line 25

def fax_entry_url
  @fax_entry_url
end

#fax_keyObject (readonly)

Returns the value of attribute fax_key.



25
26
27
# File 'lib/fax_finder/response.rb', line 25

def fax_key
  @fax_key
end

#messageObject (readonly)

Returns the value of attribute message.



25
26
27
# File 'lib/fax_finder/response.rb', line 25

def message
  @message
end

#schedule_messageObject (readonly)

Returns the value of attribute schedule_message.



25
26
27
# File 'lib/fax_finder/response.rb', line 25

def schedule_message
  @schedule_message
end

#stateObject (readonly)

Returns the value of attribute state.



25
26
27
# File 'lib/fax_finder/response.rb', line 25

def state
  @state
end

#try_numberObject (readonly)

Returns the value of attribute try_number.



25
26
27
# File 'lib/fax_finder/response.rb', line 25

def try_number
  @try_number
end

Instance Method Details

#extract_fax_and_entry_key(_url) ⇒ Object



47
48
49
50
# File 'lib/fax_finder/response.rb', line 47

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