#!/usr/local/bin/ruby require 'pp' =begin #url sample #https://anond.hatelabo.jp/archive/200609 #https://anond.hatelabo.jp/archive/201708 class AnondArchive attr_reader :url, :year, :month, :year_urls, :year_month_urls, :year_month_urls_from_200609_to_201708 def initialize(url="https://anond.hatelabo.jp/archive/")#, year, month) @url = url;# @year = year; @month = month end def add_year(from_year=Time.now.year.to_s, to_year="3000") @year_urls = [] (from_year..to_year).each do |n| # n = "0" + n.to_s unless n.to_s =~ %r|^[1][0-7]$| # @year = "20" + n#.to_s @year = n @year_urls << @url + @year end return @year_urls end def add_month(from_month=Time.now.month.to_s, to_month="12") @year_month_urls = [] @year_urls.each do |year_url| (from_month..to_month).each do |n| # n = "0" + n.to_s unless n.to_s =~ %r|^[0-9][0-2]$| @year_month_urls << year_url + n#.to_s end end return @year_month_urls end def delete_from_to(from="200101", to="200609") end def make_year_month_urls_from_200609_to_201708 @year_month_urls_from_200609_to_201708 = [] @year_month_urls.each do |year_month_url| case year_month_url when "https://anond.hatelabo.jp/archive/200601" when "https://anond.hatelabo.jp/archive/200602" when "https://anond.hatelabo.jp/archive/200603" when "https://anond.hatelabo.jp/archive/200604" when "https://anond.hatelabo.jp/archive/200605" when "https://anond.hatelabo.jp/archive/200606" when "https://anond.hatelabo.jp/archive/200607" when "https://anond.hatelabo.jp/archive/200608" when "https://anond.hatelabo.jp/archive/201709" when "https://anond.hatelabo.jp/archive/201710" when "https://anond.hatelabo.jp/archive/201711" when "https://anond.hatelabo.jp/archive/201712" else @year_month_urls_from_200609_to_201708 << year_month_url end end return @year_month_urls_from_200609_to_201708 end end anondarchive = AnondArchive.new("https://anond.hatelabo.jp/archive/") anondarchive.add_year("2001", "2017") anondarchive.add_month("01", "12") pp anondarchive.make_year_month_urls_from_200609_to_201708 =end #url sample #https://anond.hatelabo.jp/archive/200609 #https://anond.hatelabo.jp/archive/201708 class AnondArchive # attr_reader :url, :start_year, :start_month, :end_year, :end_month def initialize(url, start_year, start_month, end_year, end_month) @url = url, @start_year = start_year, @start_month = start_month, @end_year = end_year, @end_month = end_month#, @add_element = add_element end def year(from_year=Time.now.year.to_s, to_year="3000") (from_year..to_year).each do |n| @year = n end end def month(from_month=Time.now.month.to_s, to_month="12") (from_month..to_month).each do |n| @month = n end end def start_year_month#(@start_year, @start_month) @start_year_month = @start_year + @start_month end def end_year_month#(year, month) @end_year_month = @end_year + @end_month end =begin def add_url(e) @add_url = @url + e end =end def make_url_with_start_year_month#(start_year_month) # @url_with_start_year_month = @url + @start_year_month # @url + @start_year_month pp @url pp @start_year_month # add_url(@start_year_month) end def make_url_with_end_year_month#(end_year_month) @url_with_end_year_month = add_url(@end_year_month) end end anondarchive = AnondArchive.new("https://anond.hatelabo.jp/archive/", "2010", "01", "2020", "12") #pp anondarchive anondarchive.start_year_month anondarchive.end_year_month anondarchive.make_url_with_start_year_month #pp anondarchive.make_url_with_end_year_month #pp anondarchive.start_year_month#("2017", "01") #end_year_month #pp anondarchive.url_with_end_year_month #pp anondarchive.make_year_month_urls_from_200609_to_201708