Class: FaxFinder::Response
- Inherits:
-
Object
- Object
- FaxFinder::Response
- 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
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#entry_key ⇒ Object
readonly
Returns the value of attribute entry_key.
-
#fax_entry_url ⇒ Object
readonly
Returns the value of attribute fax_entry_url.
-
#fax_key ⇒ Object
readonly
Returns the value of attribute fax_key.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#schedule_message ⇒ Object
readonly
Returns the value of attribute schedule_message.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#try_number ⇒ Object
readonly
Returns the value of attribute try_number.
Instance Method Summary collapse
- #extract_fax_and_entry_key(_url) ⇒ Object
-
#initialize(_doc) ⇒ Response
constructor
A new instance of Response.
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
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
23 24 25 |
# File 'lib/fax_finder/response.rb', line 23 def doc @doc end |
#entry_key ⇒ Object (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_url ⇒ Object (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_key ⇒ Object (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 |
#message ⇒ Object (readonly)
Returns the value of attribute message.
23 24 25 |
# File 'lib/fax_finder/response.rb', line 23 def @message end |
#schedule_message ⇒ Object (readonly)
Returns the value of attribute schedule_message.
23 24 25 |
# File 'lib/fax_finder/response.rb', line 23 def @schedule_message end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
23 24 25 |
# File 'lib/fax_finder/response.rb', line 23 def state @state end |
#try_number ⇒ Object (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 |