Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/craig/tasks/update_cities.rb
Instance Method Summary collapse
- #a ⇒ Object
- #city ⇒ Object
-
#city_compressed ⇒ Object
“del rio / eagle pass” => “delrioeaglepass”.
-
#city_underscored ⇒ Object
“del rio / eagle pass” => “del_rio_eagle_pass”.
-
#initialize(node) ⇒ Node
constructor
A new instance of Node.
-
#subdomain ⇒ Object
“austin.craigslist.org” => “austin”.
- #to_s ⇒ Object
Constructor Details
#initialize(node) ⇒ Node
Returns a new instance of Node.
28 29 30 |
# File 'lib/craig/tasks/update_cities.rb', line 28 def initialize(node) @node = node end |
Instance Method Details
#a ⇒ Object
31 32 33 |
# File 'lib/craig/tasks/update_cities.rb', line 31 def a @node.at_css("a") end |
#city ⇒ Object
40 41 42 |
# File 'lib/craig/tasks/update_cities.rb', line 40 def city a.text.strip.downcase end |
#city_compressed ⇒ Object
“del rio / eagle pass” => “delrioeaglepass”
37 38 39 |
# File 'lib/craig/tasks/update_cities.rb', line 37 def city_compressed # "del rio / eagle pass" => "delrioeaglepass" city.gsub(/\W+/, "") end |
#city_underscored ⇒ Object
“del rio / eagle pass” => “del_rio_eagle_pass”
34 35 36 |
# File 'lib/craig/tasks/update_cities.rb', line 34 def city_underscored # "del rio / eagle pass" => "del_rio_eagle_pass" city.gsub(/\W+/, " ").strip.gsub(/ /, "_") end |
#subdomain ⇒ Object
“austin.craigslist.org” => “austin”
43 44 45 |
# File 'lib/craig/tasks/update_cities.rb', line 43 def subdomain # "http://austin.craigslist.org" => "austin" URI.parse(a[:href]).host.split(".").first end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/craig/tasks/update_cities.rb', line 46 def to_s "'city' => #{city_compressed}, 'sub' => #{subdomain}" end |