This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'net/http' | |
require 'openssl' | |
class UrlResolver | |
def self.resolve(uri_str, agent = 'curl/7.43.0', max_attempts = 10, timeout = 10) | |
attempts = 0 | |
cookie = nil | |
until attempts >= max_attempts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "attr_extras" # gem | |
class Month | |
vattr_initialize :year, :month_number | |
def self.from(object) | |
case object | |
when Month then object | |
else new(object.year, object.month) | |
end |