class Kamome::Operation

Constants

GENRE_GENERAL
GENRE_JIGYOSHO
TYPE_DEFAULT
TYPE_DETAIL
URL_GENERAL_ADD
URL_GENERAL_ALL
URL_GENERAL_DEL
URL_JIGYOSHO_ADD
URL_JIGYOSHO_ALL
URL_JIGYOSHO_DEL
YYMM_FORMAT

Attributes

genre[R]
type[R]
urls[R]

Public Class Methods

general_all(type: TYPE_DEFAULT) click to toggle source
# File lib/kamome/operation.rb, line 19
def general_all(type: TYPE_DEFAULT)
  new(type: type, genre: GENRE_GENERAL, urls: [URL_GENERAL_ALL])
end
general_diff(date:, type: TYPE_DEFAULT) click to toggle source
# File lib/kamome/operation.rb, line 27
def general_diff(date:, type: TYPE_DEFAULT)
  yymm = format_yymm(date)
  new(type: type, genre: GENRE_GENERAL, urls: [URL_GENERAL_ADD % yymm, URL_GENERAL_DEL % yymm])
end
jigyosho_all(type: TYPE_DEFAULT) click to toggle source
# File lib/kamome/operation.rb, line 23
def jigyosho_all(type: TYPE_DEFAULT)
  new(type: type, genre: GENRE_JIGYOSHO, urls: [URL_JIGYOSHO_ALL])
end
jigyosho_diff(date:, type: TYPE_DEFAULT) click to toggle source
# File lib/kamome/operation.rb, line 32
def jigyosho_diff(date:, type: TYPE_DEFAULT)
  yymm = format_yymm(date)
  new(type: type, genre: GENRE_JIGYOSHO, urls: [URL_JIGYOSHO_ADD % yymm, URL_JIGYOSHO_DEL % yymm])
end
new(type:, genre:, urls:) click to toggle source
# File lib/kamome/operation.rb, line 52
def initialize(type:, genre:, urls:)
  @type = type
  @genre = genre
  @urls = urls
end

Private Class Methods

format_yymm(date) click to toggle source
# File lib/kamome/operation.rb, line 40
def format_yymm(date)
  yymm = date.respond_to?(:strftime) ? date.strftime('%y%m') : date.to_s
  return yymm if yymm =~ YYMM_FORMAT

  raise ::Kamome::ArgumentError, 'Wrong argument "date" (required "yymm" format)'
end

Public Instance Methods

==(other) click to toggle source
# File lib/kamome/operation.rb, line 74
def ==(other)
  other.class == self.class && other.type == type && other.genre == genre && other.urls == urls
end
genre_general?() click to toggle source
# File lib/kamome/operation.rb, line 66
def genre_general?
  genre == GENRE_GENERAL
end
genre_jigyosho?() click to toggle source
# File lib/kamome/operation.rb, line 70
def genre_jigyosho?
  genre == GENRE_JIGYOSHO
end
type_default?() click to toggle source
# File lib/kamome/operation.rb, line 62
def type_default?
  type == TYPE_DEFAULT
end
type_detail?() click to toggle source
# File lib/kamome/operation.rb, line 58
def type_detail?
  type == TYPE_DETAIL
end