Class: Kamome::Operation
- Inherits:
-
Object
- Object
- Kamome::Operation
- Defined in:
- lib/kamome/operation.rb
Constant Summary collapse
- TYPE_DETAIL =
:detail
- TYPE_DEFAULT =
:default
- GENRE_GENERAL =
:general
- GENRE_JIGYOSHO =
:jigyosho
- URL_GENERAL_ALL =
'https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip'
- URL_GENERAL_ADD =
'https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/add_%s.zip'
- URL_GENERAL_DEL =
'https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/del_%s.zip'
- URL_JIGYOSHO_ALL =
'https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jigyosyo.zip'
- URL_JIGYOSHO_ADD =
'https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jadd%s.zip'
- URL_JIGYOSHO_DEL =
'https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jdel%s.zip'
Instance Attribute Summary collapse
-
#genre ⇒ Object
readonly
Returns the value of attribute genre.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#urls ⇒ Object
readonly
Returns the value of attribute urls.
Class Method Summary collapse
- .general_all(type: TYPE_DEFAULT) ⇒ Object
- .general_diff(date:, type: TYPE_DEFAULT) ⇒ Object
- .jigyosho_all(type: TYPE_DEFAULT) ⇒ Object
- .jigyosho_diff(date:, type: TYPE_DEFAULT) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #genre_general? ⇒ Boolean
- #genre_jigyosho? ⇒ Boolean
-
#initialize(type:, genre:, urls:) ⇒ Operation
constructor
A new instance of Operation.
- #type_default? ⇒ Boolean
- #type_detail? ⇒ Boolean
Constructor Details
#initialize(type:, genre:, urls:) ⇒ Operation
Returns a new instance of Operation.
52 53 54 55 56 |
# File 'lib/kamome/operation.rb', line 52 def initialize(type:, genre:, urls:) @type = type @genre = genre @urls = urls end |
Instance Attribute Details
#genre ⇒ Object (readonly)
Returns the value of attribute genre.
49 50 51 |
# File 'lib/kamome/operation.rb', line 49 def genre @genre end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
48 49 50 |
# File 'lib/kamome/operation.rb', line 48 def type @type end |
#urls ⇒ Object (readonly)
Returns the value of attribute urls.
50 51 52 |
# File 'lib/kamome/operation.rb', line 50 def urls @urls end |
Class Method Details
.general_all(type: TYPE_DEFAULT) ⇒ Object
19 20 21 |
# 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) ⇒ Object
27 28 29 30 |
# 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) ⇒ Object
23 24 25 |
# 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) ⇒ Object
32 33 34 35 |
# 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 |
Instance Method Details
#==(other) ⇒ Object
74 75 76 |
# 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? ⇒ Boolean
66 67 68 |
# File 'lib/kamome/operation.rb', line 66 def genre_general? genre == GENRE_GENERAL end |
#genre_jigyosho? ⇒ Boolean
70 71 72 |
# File 'lib/kamome/operation.rb', line 70 def genre_jigyosho? genre == GENRE_JIGYOSHO end |
#type_default? ⇒ Boolean
62 63 64 |
# File 'lib/kamome/operation.rb', line 62 def type_default? type == TYPE_DEFAULT end |
#type_detail? ⇒ Boolean
58 59 60 |
# File 'lib/kamome/operation.rb', line 58 def type_detail? type == TYPE_DETAIL end |