Module: Zakuro::Operation::TypeParser

Defined in:
lib/zakuro/operation/month/parser.rb

Overview

TypeParser 型ごと変換

Class Method Summary collapse

Class Method Details

.days(str:) ⇒ Integer

日(差分)を変換する

Parameters:

  • str (String)

    文字列

Returns:

  • (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

無効値かを判定する

Parameters:

  • str (String)

    文字列

Returns:

  • (True)

    無効値

  • (False)

    有効値



27
28
29
# File 'lib/zakuro/operation/month/parser.rb', line 27

def invalid?(str:)
  str == '-'
end

.modified?(str:) ⇒ True, False

有効行を変換する

Parameters:

  • str (String)

    文字列

Returns:

  • (True)

    有効

  • (False)

    無効



45
46
47
# File 'lib/zakuro/operation/month/parser.rb', line 45

def modified?(str:)
  str == 'true'
end

.month_leaped(str:) ⇒ True

閏有無を変換する

Parameters:

  • str (String)

    文字列

Returns:

  • (True)

    閏あり

  • (True)

    閏なし/閏設定なし



70
71
72
# File 'lib/zakuro/operation/month/parser.rb', line 70

def month_leaped(str:)
  str == 'true'
end

.month_number(str:) ⇒ Integer

月を変換する

Parameters:

  • str (String)

    文字列

Returns:

  • (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

西暦日を変換する

Parameters:

  • str (String)

    文字列

Returns:



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