Class: SRCEITools::ValidateDI
- Inherits:
-
Object
- Object
- SRCEITools::ValidateDI
- Defined in:
- lib/srcei-tools/validate_di.rb
Instance Attribute Summary collapse
-
#doc_run ⇒ Object
writeonly
Sets the attribute doc_run.
-
#doc_type ⇒ Object
writeonly
Sets the attribute doc_type.
Class Method Summary collapse
Instance Method Summary collapse
- #check_document ⇒ Object
-
#initialize(doc_run, doc_type, doc_number) ⇒ ValidateDI
constructor
A new instance of ValidateDI.
Constructor Details
#initialize(doc_run, doc_type, doc_number) ⇒ ValidateDI
Returns a new instance of ValidateDI.
15 16 17 18 19 |
# File 'lib/srcei-tools/validate_di.rb', line 15 def initialize(doc_run, doc_type, doc_number) self.doc_run = doc_run self.doc_type = doc_type @doc_number = doc_number end |
Instance Attribute Details
#doc_run=(value) ⇒ Object (writeonly)
Sets the attribute doc_run
6 7 8 |
# File 'lib/srcei-tools/validate_di.rb', line 6 def doc_run=(value) @doc_run = value end |
#doc_type=(doc_type) ⇒ Object (writeonly)
Sets the attribute doc_type
5 6 7 |
# File 'lib/srcei-tools/validate_di.rb', line 5 def doc_type=(value) @doc_type = value end |
Class Method Details
.valid?(doc_run, doc_type, doc_number) ⇒ Boolean
21 22 23 |
# File 'lib/srcei-tools/validate_di.rb', line 21 def self.valid?(doc_run, doc_type, doc_number) new( doc_run, doc_type, doc_number ).check_document end |
Instance Method Details
#check_document ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/srcei-tools/validate_di.rb', line 25 def check_document # URL SRCEI to validate document url = 'https://portal.sidiv.registrocivil.cl/usuarios-portal/pages/DocumentRequestStatus.xhtml' # Set Agent to navigate web a = Mechanize.new do |agent| agent.user_agent_alias = 'Mac Safari' agent.verify_mode = OpenSSL::SSL::VERIFY_NONE end begin a.get(url) do |page| form = page.form_with(:id => 'form') do |f| f['form:run'] = @doc_run f['form:selectDocType'] = @doc_type f['form:docNumber'] = @doc_number end. doc = form.parser # Get value (Vigente | No Vigente | Empty) status = doc.at('tr [@class="setWidthOfSecondColumn"]').text if( status == 'Vigente' ) return true else return false end end rescue Mechanize::ResponseCodeError => e return false end end |