Class: Barometer::Query::Format::WoeID

Inherits:
Base
  • Object
show all
Defined in:
lib/barometer/query/formats/woe_id.rb

Overview

WOEID: “Where on Earth” ID (by Yahoo!) eg. 2459115, 615702 or w90210

NOTE: zipcodes and WoeIDs can look exactly the same when the WoeID

is 5 digits long.  For now, a 5 digit number will be detected as
zipcode.  The way to override this is to prepend a number with the
letter 'w'.  Therefore 90210 will be a zipcode and w90210 will be
a WoeID.

Class Method Summary collapse

Methods inherited from Base

geo, is?

Class Method Details

.convert_query(text) ⇒ Object

remove the ‘w’ from applicable queries (only needed for detection)



19
20
21
22
# File 'lib/barometer/query/formats/woe_id.rb', line 19

def self.convert_query(text)
  return nil unless text
  text.delete('w')
end

.regexObject



15
# File 'lib/barometer/query/formats/woe_id.rb', line 15

def self.regex; /(^[0-9]{4}$)|(^[0-9]{6,7}$)|(^w[0-9]{4,7}$)/; end