Class: Geostats::Grabber::Cache
- Inherits:
-
Object
- Object
- Geostats::Grabber::Cache
- Defined in:
- lib/geostats/grabber/cache.rb
Instance Method Summary collapse
- #archived? ⇒ Boolean
- #code ⇒ Object
- #difficulty ⇒ Object
- #dnf_count ⇒ Object
- #founds_count ⇒ Object
- #hidden_at ⇒ Object
-
#initialize(uuid) ⇒ Cache
constructor
A new instance of Cache.
- #latitude ⇒ Object
- #location ⇒ Object
- #longitude ⇒ Object
- #name ⇒ Object
- #owner ⇒ Object
- #pmonly? ⇒ Boolean
- #size ⇒ Object
- #terrain ⇒ Object
- #type ⇒ Object
Constructor Details
Instance Method Details
#archived? ⇒ Boolean
86 87 88 |
# File 'lib/geostats/grabber/cache.rb', line 86 def archived? !!(@data =~ /<li>This cache has been archived/) end |
#code ⇒ Object
8 9 10 11 12 |
# File 'lib/geostats/grabber/cache.rb', line 8 def code if @data =~ /<div id="ctl00_cacheCodeWidget".*?>\s*<p>\s*([A-Z0-9]+)<\/p>\s*<\/div>/ $1 end end |
#difficulty ⇒ Object
48 49 50 51 52 |
# File 'lib/geostats/grabber/cache.rb', line 48 def difficulty if @data =~ /<span id="ctl00_ContentBody_Difficulty"><img src=".*?" alt="([0-9\.]+) out of 5" \/><\/span>/ $1.to_f end end |
#dnf_count ⇒ Object
82 83 84 |
# File 'lib/geostats/grabber/cache.rb', line 82 def dnf_count @data.scan(/<strong><img src=".*?icon_sad\.gif" alt="" \/> /).length end |
#founds_count ⇒ Object
78 79 80 |
# File 'lib/geostats/grabber/cache.rb', line 78 def founds_count @data.scan(/<strong><img src=".*?icon_smile\.gif" alt="" \/> /).length end |
#hidden_at ⇒ Object
27 28 29 30 31 |
# File 'lib/geostats/grabber/cache.rb', line 27 def hidden_at if @data =~ /<span id="ctl00_ContentBody_DateHidden">(\d{1,2})\/(\d{1,2})\/(\d{4})<\/span>/ Time.parse([$2, $1, $3].join(".")) end end |
#latitude ⇒ Object
60 61 62 63 64 |
# File 'lib/geostats/grabber/cache.rb', line 60 def latitude if @data =~ /\/wpt\/\?lat=(.*)&lon=(.*)&detail=1/ $1.to_f end end |
#location ⇒ Object
72 73 74 75 76 |
# File 'lib/geostats/grabber/cache.rb', line 72 def location if @data =~ /<span id="ctl00_ContentBody_Location">In (.*?)<\/span>/ $1 end end |
#longitude ⇒ Object
66 67 68 69 70 |
# File 'lib/geostats/grabber/cache.rb', line 66 def longitude if @data =~ /\/wpt\/\?lat=(.*)&lon=(.*)&detail=1/ $2.to_f end end |
#name ⇒ Object
14 15 16 17 18 19 |
# File 'lib/geostats/grabber/cache.rb', line 14 def name if @data =~ /<span id="ctl00_ContentBody_CacheName">(.*?)<\/span>/ name = Utils.unescape($1) name =~ /^<strike>(.*)<\/strike>$/ ? $1 : name end end |
#owner ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/geostats/grabber/cache.rb', line 39 def owner if @data =~ /<span id="ctl00_ContentBody_CacheOwner">by.*?\/profile\/\?guid=(.*?)&wid=.*<\/a><\/span>/ user = Grabber::User.new($1) if name = user.username name end end end |
#pmonly? ⇒ Boolean
90 91 92 |
# File 'lib/geostats/grabber/cache.rb', line 90 def pmonly? !!(@data =~ /<p class="Warning">Sorry, the owner of this listing has made it viewable to Premium Members only./) end |
#size ⇒ Object
33 34 35 36 37 |
# File 'lib/geostats/grabber/cache.rb', line 33 def size if @data =~ /<img src="\/images\/icons\/container\/(.*?)\.gif" alt="Size: .*?" \/>/ $1 if %w(micro small regular large other not_chosen).include?($1) end end |
#terrain ⇒ Object
54 55 56 57 58 |
# File 'lib/geostats/grabber/cache.rb', line 54 def terrain if @data =~ /<span id="ctl00_ContentBody_Terrain"><img src=".*?" alt="([0-9\.]+) out of 5" \/><\/span>/ $1.to_f end end |
#type ⇒ Object
21 22 23 24 25 |
# File 'lib/geostats/grabber/cache.rb', line 21 def type if @data =~ /<h2.*?WptTypes\/(\d+)\.gif".*?h2>/ $1.to_i end end |