class BestNomadCities::City
Attributes
cost[RW]
country[RW]
internet_speed[RW]
link[RW]
name[RW]
rank[RW]
tg_link[RW]
weather[RW]
Public Class Methods
all()
click to toggle source
# File lib/best_nomad_cities/city.rb, line 18 def self.all @@all end
new(attrs)
click to toggle source
# File lib/best_nomad_cities/city.rb, line 6 def initialize(attrs) @name = attrs[:name] @country = attrs[:country] @rank = attrs[:rank] @cost = attrs[:cost] @internet_speed = attrs[:internet_speed] @weather = attrs[:weather] @link = attrs[:link] @tg_link = attrs[:tg_link] @@all << self end
sort_by_cost()
click to toggle source
# File lib/best_nomad_cities/city.rb, line 22 def self.sort_by_cost @@all.sort! do |a,b| b.cost.scan(/\d/).join('').to_i <=> a.cost.scan(/\d/).join('').to_i end end