Class: Wfrmls::IE

Inherits:
Object
  • Object
show all
Defined in:
lib/wfrmls/ie.rb

Instance Method Summary collapse

Constructor Details

#initialize(ie, username, password) ⇒ IE

Returns a new instance of IE.



8
9
10
11
12
# File 'lib/wfrmls/ie.rb', line 8

def initialize(ie, username, password)
  @username = username
  @password = password
  @ie = ie
end

Instance Method Details

#collect_property_details(addr) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/wfrmls/ie.rb', line 52

def collect_property_details(addr)
  show_tax_data(addr) unless @ie.url.include? 'taxdata/details'

  doc = @ie.xmlparser_document_object

  details = {}

  doc.search('tr/th').each do |item|
    case nbsp2sp(item.text)
    when /NAME:/
      details[:owner] = item.parent.search('td').text
    when /ADDRESS:/
      details[:address] = item.parent.search('td').text.strip
    when /PARCEL SPECIFIC INFO:/
      nbsp2sp(item.parent.search('td').text) =~ /Total Acres: ([.0-9]+)/
      details[:lot_size] = $1
    when /VALUATION SPECIFIC INFO:/
      nbsp2sp(item.parent.search('td').text) =~ /Final Value: (\$[0-9,]+)/
      details[:tax_value] = $1
    when /GENERAL INFO:/
      nbsp2sp(item.parent.search('td').text) =~ /Yr Built: ([0-9]+)/
      details[:year_built] = $1.to_i
    when /AREA INFO:/
      house_size = 0
      data = nbsp2sp(item.parent.search('td').text)
      data =~ /Main Floor Area: ([,0-9]+)/
      house_size += $1.sub(',','').to_i if $1
      data =~ /Basement Area: ([,0-9]+)/
      house_size += $1.sub(',','').to_i if $1
      data =~ /Upper Floor Area: ([,0-9]+)/
      house_size += $1.sub(',','').to_i if $1
      details[:house_size] = house_size
    when /EXTERIOR:/
      details[:exterior] ||= {}
      data = nbsp2sp(item.parent.search('td').text)
      data =~ /Ext. Wall Type: (\w+)/
      details[:exterior][:wall] = $1
      data =~ /Masonry Trim: (\w+)/
      details[:exterior][:masonry_trim] = $1
    when /CARPORT & GARAGE INFO:/
      data = nbsp2sp(item.parent.search('td').text)
      data =~ /(.*): ([0-9]+)/
      details[:parking] = nil
      if $1
        details[:parking] = {}
        details[:parking][$1] = $2.to_i
      end
    end
  end

  details
end

#comp(addr, house_details = collect_property_details(addr)) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/wfrmls/ie.rb', line 29

def comp(addr, house_details = collect_property_details(addr))
  goto_search_page
  historical_data
  status
  city(addr.city)
  short_sale(false)

  @ie.text_field(:id, 'days_back_status').set('120')


  @ie.text_field(:name,'tot_sqf1').set((house_details[:house_size]-200).to_s)
  @ie.text_field(:name,'tot_sqf2').set((house_details[:house_size]+200).to_s)

  @ie.text_field(:name,'yearblt1').set((house_details[:year_built]-6).to_s)
  @ie.text_field(:name,'yearblt2').set((house_details[:year_built]+6).to_s)

  sleep_until(3) {
    @ie.dd(:id,'left_search_criteria').text.include? 'Year Built at most'
  }

  show_full_listings
end

#lookup_address(addr) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/wfrmls/ie.rb', line 14

def lookup_address(addr)
  find_address_on_search_page(addr)

  if search_results_availible?
    show_full_listings
  else
    show_tax_data(addr)
  end
end

#lookup_opposition(addr) ⇒ Object



24
25
26
27
# File 'lib/wfrmls/ie.rb', line 24

def lookup_opposition(addr)
  find_address_on_search_page(addr)
  show_listings
end

#show_tax_data(addr) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/wfrmls/ie.rb', line 105

def show_tax_data(addr)
  goto "http://www.utahrealestate.com/taxdata/index?county%5B%5D=2&county%5B%5D=8&searchtype=house&searchbox=#{addr.number}"

  rows = find_tax_data_rows_by_house_and_street(addr)

  case rows.size
  when 0
    puts "#{addr} not found in tax data"
  when 1
    click_link rows[0]
  else
    puts 'Possible matches:'
    rows.each do |item|
      puts item.cell(:class, 'last-col').text
    end
    regex = /\b#{addr.prefix}\b.*\b#{addr.suffix}/
    rows = rows.inject([]) do |c, item|
      c << item if regex.match item.cell(:class, 'last-col').text
      c
    end
    case rows.size
    when 0
      puts "#{addr} not found with #{regex}"
    when 1
      click_link rows[0]
    else
      puts 'Possible matches:'
      rows.each do |item|
        puts item.cell(:class, 'last-col').text
      end
    end
  end
end