Module: Zakuro::Operation::TypeParser
- Defined in:
- lib/zakuro/operation/month/parser.rb
Overview
TypeParser 型ごと変換
Class Method Summary collapse
-
.days(str:) ⇒ Integer
日(差分)を変換する.
-
.invalid?(str:) ⇒ True, False
無効値かを判定する.
-
.modified?(str:) ⇒ True, False
有効行を変換する.
-
.month_leaped(str:) ⇒ True
閏有無を変換する.
-
.month_number(str:) ⇒ Integer
月を変換する.
- .solar_term_index(str:) ⇒ Object
- .text(str:) ⇒ Object
-
.western_date(str:) ⇒ Western::Calendar
西暦日を変換する.
Class Method Details
.days(str:) ⇒ Integer
日(差分)を変換する
94 95 96 97 98 |
# File 'lib/zakuro/operation/month/parser.rb', line 94 def days(str:) return INVALID_DAY_VALUE if invalid?(str: str) str.to_i end |
.invalid?(str:) ⇒ True, False
無効値かを判定する
27 28 29 |
# File 'lib/zakuro/operation/month/parser.rb', line 27 def invalid?(str:) str == '-' end |
.modified?(str:) ⇒ True, False
有効行を変換する
45 46 47 |
# File 'lib/zakuro/operation/month/parser.rb', line 45 def modified?(str:) str == 'true' end |
.month_leaped(str:) ⇒ True
閏有無を変換する
70 71 72 |
# File 'lib/zakuro/operation/month/parser.rb', line 70 def month_leaped(str:) str == 'true' end |
.month_number(str:) ⇒ Integer
月を変換する
56 57 58 59 60 |
# File 'lib/zakuro/operation/month/parser.rb', line 56 def month_number(str:) return -1 if invalid?(str: str) str.to_i end |
.solar_term_index(str:) ⇒ Object
100 101 102 103 104 |
# File 'lib/zakuro/operation/month/parser.rb', line 100 def solar_term_index(str:) return -1 if invalid?(str: str) str.to_i end |
.text(str:) ⇒ Object
31 32 33 34 35 |
# File 'lib/zakuro/operation/month/parser.rb', line 31 def text(str:) return '' if invalid?(str: str) str end |
.western_date(str:) ⇒ Western::Calendar
西暦日を変換する
81 82 83 84 85 |
# File 'lib/zakuro/operation/month/parser.rb', line 81 def western_date(str:) return Western::Calendar.new if invalid?(str: str) Western::Calendar.parse(text: str) end |