zakuro 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
  3. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
  4. data/lib/zakuro/calculation/base/year.rb +107 -0
  5. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +471 -0
  6. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
  7. data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
  8. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +169 -0
  9. data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
  10. data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
  11. data/lib/zakuro/calculation/monthly/month.rb +187 -0
  12. data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
  13. data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
  14. data/lib/zakuro/calculation/range/full_range.rb +210 -0
  15. data/lib/zakuro/calculation/range/medieval_annual_range.rb +105 -0
  16. data/lib/zakuro/calculation/range/operated_range.rb +144 -0
  17. data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
  18. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
  19. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
  20. data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
  21. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +76 -0
  22. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +52 -0
  23. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +117 -0
  24. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +187 -0
  25. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +136 -0
  26. data/lib/zakuro/calculation/summary/single.rb +129 -0
  27. data/lib/zakuro/calculation/type/old_float.rb +69 -0
  28. data/lib/zakuro/merchant.rb +2 -2
  29. data/lib/zakuro/operation/month/parser.rb +1 -1
  30. data/lib/zakuro/operation/month/type.rb +5 -10
  31. data/lib/zakuro/output/error.rb +7 -6
  32. data/lib/zakuro/output/logger.rb +50 -49
  33. data/lib/zakuro/output/response.rb +145 -144
  34. data/lib/zakuro/tools/typeof.rb +2 -2
  35. data/lib/zakuro/version.rb +1 -1
  36. data/lib/zakuro/version/abstract_version.rb +1 -1
  37. data/lib/zakuro/version/context.rb +23 -0
  38. data/lib/zakuro/version/gihou/const/number.rb +55 -0
  39. data/lib/zakuro/version/gihou/const/remainder.rb +56 -0
  40. data/lib/zakuro/version/gihou/cycle/remainder.rb +61 -0
  41. data/lib/zakuro/version/gihou/cycle/solar_term.rb +34 -0
  42. data/lib/zakuro/version/gihou/gihou.rb +23 -2
  43. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +106 -0
  44. data/lib/zakuro/version/gihou/range/annual_range.rb +39 -0
  45. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +250 -0
  46. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +44 -0
  47. data/lib/zakuro/version/gihou/stella/lunar/location.rb +86 -0
  48. data/lib/zakuro/version/gihou/stella/lunar/value.rb +74 -0
  49. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +34 -0
  50. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +62 -0
  51. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +55 -0
  52. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +93 -0
  53. data/lib/zakuro/version/gihou/stella/solar/average.rb +97 -0
  54. data/lib/zakuro/version/gihou/stella/solar/interval.rb +108 -0
  55. data/lib/zakuro/version/gihou/stella/solar/location.rb +61 -0
  56. data/lib/zakuro/version/gihou/stella/solar/value.rb +36 -0
  57. data/lib/zakuro/version/senmyou/const/number.rb +51 -0
  58. data/lib/zakuro/version/senmyou/const/remainder.rb +49 -0
  59. data/lib/zakuro/version/senmyou/cycle/remainder.rb +61 -0
  60. data/lib/zakuro/version/senmyou/cycle/solar_term.rb +34 -0
  61. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +80 -195
  62. data/lib/zakuro/version/senmyou/range/annual_range.rb +25 -170
  63. data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
  64. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
  65. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +44 -0
  66. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +93 -0
  67. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +66 -0
  68. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
  69. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
  70. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
  71. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
  72. data/lib/zakuro/version/senmyou/stella/solar/average.rb +97 -0
  73. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
  74. data/lib/zakuro/version/senmyou/stella/solar/location.rb +61 -0
  75. data/lib/zakuro/version/senmyou/stella/solar/value.rb +39 -0
  76. data/lib/zakuro/version/version_class_resolver.rb +66 -0
  77. data/lib/zakuro/version_factory.rb +2 -2
  78. metadata +64 -24
  79. data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
  80. data/lib/zakuro/cycle/zodiac.rb +0 -103
  81. data/lib/zakuro/version/senmyou/base/era.rb +0 -83
  82. data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
  83. data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
  84. data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
  85. data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -86
  86. data/lib/zakuro/version/senmyou/base/year.rb +0 -104
  87. data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
  88. data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -48
  89. data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
  90. data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
  91. data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -167
  92. data/lib/zakuro/version/senmyou/range/full_range.rb +0 -324
  93. data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -126
  94. data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -181
  95. data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -102
  96. data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
  97. data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -214
  98. data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -394
  99. data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
  100. data/lib/zakuro/version/senmyou/summary/single.rb +0 -125
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../type/old_float'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ # :nodoc:
8
+ module Calculation
9
+ # :nodoc:
10
+ module Solar
11
+ #
12
+ # ChoukeiValue 再考長慶宣明暦算法
13
+ #
14
+ module ChoukeiValue
15
+ # @return [Output::Logger] ロガー
16
+ LOGGER = Output::Logger.new(location: 'solar_choukei')
17
+
18
+ #
19
+ # 補正値を返す
20
+ #
21
+ # @param [Cycle::AbstractRemainder] remainder 大余小余
22
+ # @param [Adjustment::Row] row 24気損益眺朒(ちょうじく)数
23
+ #
24
+ # @return [Integer] 補正値
25
+ #
26
+ def self.get(remainder:, row:)
27
+ # 損益率/眺朒(ちょうじく)数
28
+ # パラメータ:
29
+ # a: 眺朒(ちょうじく)数の初日の値
30
+ # b: 損益率初日の値
31
+ # c: 損益率の毎日の差
32
+ # n: 定気の日から数えた日数
33
+
34
+ # LOGGER.debug("row.per_day: #{row.per_day}")
35
+ # LOGGER.debug("row.stack: #{row.stack}")
36
+
37
+ day_stack = calc_day_stack(remainder: remainder, row: row)
38
+
39
+ # LOGGER.debug("day_stack: #{day_stack}")
40
+
41
+ month_stack = calc_month_stack(row: row, day: remainder.day)
42
+
43
+ # LOGGER.debug("month_stack: #{month_stack}")
44
+
45
+ # 冬至であれば眺朒数がプラスになり続けて損益率が「益」で、小雪であればマイナスの眺朒数がプラスされ続けて「損」
46
+ month_stack + day_stack
47
+ end
48
+
49
+ #
50
+ # 損益率を求める
51
+ #
52
+ # @param [Remainder] remainder 入定気
53
+ # @param [Adjustment::Row] row 24気損益眺朒(ちょうじく)数
54
+ #
55
+ # @return [Integer] 損益率
56
+ #
57
+ def self.calc_day_stack(remainder:, row:)
58
+ ratio = calc_ratio(day: remainder.day, per_term: row.per_term, per_day: row.per_day)
59
+
60
+ # LOGGER.debug("ratio.sign: #{ratio.sign}")
61
+ # LOGGER.debug("ratio.abs: #{ratio.abs}")
62
+
63
+ calc_day_stack_from_ratio(
64
+ ratio: ratio, minute: remainder.minute, limit: remainder.base_day
65
+ )
66
+ end
67
+ private_class_method :calc_day_stack
68
+
69
+ #
70
+ # 大余に対応する損益率を求める
71
+ # 損益率 = b + n * c
72
+ #
73
+ # @param [Integer] day 大余
74
+ # @param [Integer] per_term 眺朒(ちょうじく)数
75
+ # @param [Integer] per_day 毎日差
76
+ #
77
+ # @return [Type::OldFloat] 大余に対応する損益率
78
+ #
79
+ def self.calc_ratio(day:, per_term:, per_day:)
80
+ ratio = Type::OldFloat.new(per_term + day * per_day)
81
+ # 小数点以下は無視する
82
+ ratio.floor!
83
+
84
+ ratio
85
+ end
86
+ private_class_method :calc_ratio
87
+
88
+ #
89
+ # 小余を含めた損益率を求める
90
+ #
91
+ # @param [Integer] sign 正負(大余に対応する損益率)
92
+ # @param [Integer] ratio 大余に対応する損益率
93
+ # @param [Integer] minute 小余
94
+ #
95
+ # @return [Integer] 小余を含めた損益率
96
+ #
97
+ def self.calc_day_stack_from_ratio(ratio:, minute:, limit:)
98
+ minute_stack = ratio.abs * minute
99
+ day_stack = (minute_stack / limit).floor
100
+ # 四捨五入
101
+ # NOTE 資料では「この余りが4200をこえていれば切り上げる」とあり「>=」とした
102
+ # 1612年の7月(慶長17年7月)が境界値4200だが、繰り上げを行なっていたため
103
+ day_stack += 1 if minute_stack % limit >= (limit / 2)
104
+ day_stack *= ratio.sign
105
+
106
+ day_stack
107
+ end
108
+ private_class_method :calc_day_stack_from_ratio
109
+
110
+ #
111
+ # 眺朒(ちょうじく)数を求める
112
+ # 眺朒(ちょうじく)数 = a + (n * b) + (1/2)n(n-1)c
113
+ #
114
+ # @param [Adjustment::Row] row 24気損益眺朒(ちょうじく)数
115
+ # @param [Integer] day 大余
116
+ #
117
+ # @return [Integer] 眺朒(ちょうじく)数
118
+ #
119
+ def self.calc_month_stack(row:, day:)
120
+ # row.stack: 眺朒(ちょうじく)積
121
+ # row.per_term: 眺朒(ちょうじく)数
122
+ # row.per_day: 毎日差
123
+ month_stack = Type::OldFloat.new(
124
+ row.stack + day * row.per_term + \
125
+ (1 / 2.0) * (day * (day - 1) * row.per_day)
126
+ )
127
+ # 切り捨て(プラスマイナスに関わらず小数点以下切り捨て)
128
+ month_stack.floor!
129
+
130
+ month_stack.get
131
+ end
132
+ private_class_method :calc_month_stack
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../specifier/single_day'
4
+
5
+ require_relative '../range/operated_range'
6
+
7
+ require_relative '../range/full_range'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Calculation
13
+ # :nodoc:
14
+ module Summary
15
+ #
16
+ # Single 一日
17
+ #
18
+ module Single
19
+ #
20
+ # 生成する
21
+ #
22
+ # @param [Context] context 暦コンテキスト
23
+ # @param [Western::Calendar] date 西暦日
24
+ #
25
+ # @return [Result::Single] 一日検索結果(和暦日)
26
+ #
27
+ def self.get(context:, date: Western::Calendar.new)
28
+ full_range = Calculation::Range::FullRange.new(context: context, start_date: date)
29
+ years = full_range.get
30
+
31
+ calc_date = Calculation::Specifier::SingleDay.get(
32
+ years: years, date: date
33
+ )
34
+
35
+ operated_range = Calculation::Range::OperatedRange.new(context: context, years: years)
36
+
37
+ Result::Single.new(
38
+ data: Calculation::Specifier::SingleDay.get(
39
+ years: operated_range.get, date: date
40
+ ),
41
+ operation: create_operation(calc_date: calc_date)
42
+ )
43
+ end
44
+
45
+ #
46
+ # 運用情報を生成する
47
+ #
48
+ # @param [Result::Data::SingleDay] calc_date 和暦日(計算値)
49
+ #
50
+ # @return [Result::Operation::Bundle] 運用情報
51
+ #
52
+ def self.create_operation(calc_date: Result::Data::SingleDay.new)
53
+ first_day = calc_date.month.first_day.western_date
54
+ operation_history = Operation.specify_history(western_date: first_day)
55
+
56
+ operation_month = create_operation_month(operation_history: operation_history)
57
+
58
+ Result::Operation::Bundle.new(
59
+ operated: !operation_history.invalid?, month: operation_month, original: calc_date
60
+ )
61
+ end
62
+ private_class_method :create_operation
63
+
64
+ #
65
+ # 月履歴集約情報を生成する
66
+ #
67
+ # @param [Operation::MonthHistory] operation_history 変更履歴(月)
68
+ #
69
+ # @return [Result::Operation::Month::Bundle] 月履歴集約情報
70
+ #
71
+ def self.create_operation_month(operation_history: Operation::MonthHistory.new)
72
+ return Result::Operation::Month::Bundle.new if operation_history.invalid?
73
+
74
+ parent_operation_history = Operation.specify_history_by_id(
75
+ id: operation_history.parent_id
76
+ )
77
+
78
+ Result::Operation::Month::Bundle.new(
79
+ current: create_operation_month_history(operation_history: operation_history),
80
+ parent: create_operation_month_history(operation_history: parent_operation_history)
81
+ )
82
+ end
83
+ private_class_method :create_operation_month
84
+
85
+ #
86
+ # 月別履歴情報を生成する
87
+ #
88
+ # @param [Operation::MonthHistory] operation_history 変更履歴(月)
89
+ #
90
+ # @return [Result::Operation::Month::History] 月別履歴情報
91
+ #
92
+ def self.create_operation_month_history(operation_history: Operation::MonthHistory.new)
93
+ return Result::Operation::Month::History.new if operation_history.invalid?
94
+
95
+ annotations = create_annnotations(operation_history: operation_history)
96
+
97
+ reference = operation_history.reference
98
+ Result::Operation::Month::History.new(
99
+ id: operation_history.id, western_date: operation_history.western_date.format,
100
+ page: reference.page, number: reference.number, annotations: annotations
101
+ )
102
+ end
103
+ private_class_method :create_operation_month_history
104
+
105
+ #
106
+ # 注釈情報を生成する
107
+ #
108
+ # @param [Operation::MonthHistory] operation_history 変更履歴(月)
109
+ #
110
+ # @return [Array<Result::Operation::Month::Annotation>] 注釈
111
+ #
112
+ def self.create_annnotations(operation_history: Operation::MonthHistory.new)
113
+ annotations = []
114
+ operation_history.annotations.each do |annotation|
115
+ annotations.push(
116
+ Result::Operation::Month::Annotation.new(
117
+ description: annotation.description,
118
+ note: annotation.note
119
+ )
120
+ )
121
+ end
122
+
123
+ annotations
124
+ end
125
+ private_class_method :create_annnotations
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Zakuro
5
+ # :nodoc:
6
+ module Calculation
7
+ # :nodoc:
8
+ module Type
9
+ #
10
+ # OldFloat 浮動小数点数(古代)
11
+ #
12
+ # @note 四捨五入は常に絶対値に対して行う
13
+ # * value.negative? ? value.ceil : value.floor
14
+ # * 絶対値だけを取り出すことで、四捨五入を平易にする
15
+ #
16
+ class OldFloat
17
+ # @return [Integer] 符号
18
+ attr_reader :sign
19
+ # @return [Float] 絶対値
20
+ attr_reader :abs
21
+
22
+ #
23
+ # 初期化
24
+ #
25
+ # @param [Float] value 符号つき浮動小数点数
26
+ #
27
+ def initialize(value)
28
+ @sign = value.negative? ? -1 : 1
29
+ @abs = @sign * value
30
+ end
31
+
32
+ #
33
+ # 四捨五入する
34
+ #
35
+ def floor!
36
+ @abs = floor
37
+ end
38
+
39
+ #
40
+ # 四捨五入する(非破壊的)
41
+ #
42
+ # @return [Float] 絶対値
43
+ #
44
+ def floor
45
+ @abs.floor
46
+ end
47
+
48
+ #
49
+ # 符号つき浮動小数点数を取得する
50
+ #
51
+ # @return [Float] 符号つき浮動小数点数
52
+ #
53
+ def get
54
+ @sign * @abs
55
+ end
56
+
57
+ #
58
+ # 負数かどうか
59
+ #
60
+ # @return [True] 負数
61
+ # @return [False] 正数
62
+ #
63
+ def negative?
64
+ @sign == -1
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -22,7 +22,7 @@ module Zakuro
22
22
  #
23
23
  def initialize(condition: {})
24
24
  failed = Condition.validate(hash: condition)
25
- raise ZakuroError, failed.join('\n') unless failed.empty?
25
+ raise Output::ZakuroError, failed.join('\n') unless failed.empty?
26
26
 
27
27
  @condition = Condition.new(hash: condition)
28
28
  end
@@ -36,7 +36,7 @@ module Zakuro
36
36
  #
37
37
  def offer(condition: {})
38
38
  failed = Condition.validate(hash: condition)
39
- raise ZakuroError, failed.join('\n') unless failed.empty?
39
+ raise Output::ZakuroError, failed.join('\n') unless failed.empty?
40
40
 
41
41
  @condition.rewrite(hash: condition)
42
42
 
@@ -340,7 +340,7 @@ module Zakuro
340
340
  Month.new(
341
341
  number: create_month_number(yaml_hash: yaml_hash['number']),
342
342
  leaped: create_month_leaped(yaml_hash: yaml_hash['leaped']),
343
- days: create_month_day(yaml_hash: yaml_hash['days'])
343
+ is_many_days: create_month_day(yaml_hash: yaml_hash['days'])
344
344
  )
345
345
  end
346
346
  private_class_method :create_month
@@ -186,7 +186,7 @@ module Zakuro
186
186
  # @return [Leaped] 閏有無
187
187
  attr_reader :leaped
188
188
  # @return [Days] 月の大小
189
- attr_reader :days
189
+ attr_reader :is_many_days
190
190
 
191
191
  # :reek:BooleanParameter
192
192
 
@@ -197,10 +197,10 @@ module Zakuro
197
197
  # @param [Leaped] leaped 閏有無
198
198
  # @param [Days] days 月の大小
199
199
  #
200
- def initialize(number: Number.new, leaped: Leaped.new, days: Days.new)
200
+ def initialize(number: Number.new, leaped: Leaped.new, is_many_days: Days.new)
201
201
  @number = number
202
202
  @leaped = leaped
203
- @days = days
203
+ @is_many_days = is_many_days
204
204
  end
205
205
 
206
206
  #
@@ -408,11 +408,6 @@ module Zakuro
408
408
  # @return [String] 30日
409
409
  BIG = '大'
410
410
 
411
- # @return [String] 計算
412
- attr_reader :calc
413
- # @return [String] 運用
414
- attr_reader :actual
415
-
416
411
  #
417
412
  # 初期化
418
413
  #
@@ -430,7 +425,7 @@ module Zakuro
430
425
  # @return [True] 大
431
426
  # @return [False] 小
432
427
  #
433
- def many_days_calc?
428
+ def calc
434
429
  @calc == BIG
435
430
  end
436
431
 
@@ -440,7 +435,7 @@ module Zakuro
440
435
  # @return [True] 大
441
436
  # @return [False] 小
442
437
  #
443
- def many_days_actual?
438
+ def actual
444
439
  @actual == BIG
445
440
  end
446
441
 
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO: outputモジュール内にする
4
-
5
3
  # :nodoc:
6
4
  module Zakuro
7
- #
8
- # ZakuroError ライブラリ内エラー
9
- #
10
- class ZakuroError < StandardError
5
+ # :nodoc:
6
+ module Output
7
+ #
8
+ # ZakuroError ライブラリ内エラー
9
+ #
10
+ class ZakuroError < StandardError
11
+ end
11
12
  end
12
13
  end
@@ -1,65 +1,66 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO: outputモジュール内にする
4
-
5
3
  # :nodoc:
6
4
  module Zakuro
7
- #
8
- # 軽量なロガー
9
- # @note 本番では使用しない
10
- #
11
- class Logger
12
- LEVELS = {
13
- none: -1,
14
- debug: 0,
15
- info: 1
16
- # warn : 2,
17
- # error : 3,
18
- }.freeze
5
+ # :nodoc:
6
+ module Output
7
+ #
8
+ # 軽量なロガー
9
+ # @note 本番では使用しない
10
+ #
11
+ class Logger
12
+ LEVELS = {
13
+ none: -1,
14
+ debug: 0,
15
+ info: 1
16
+ # warn : 2,
17
+ # error : 3,
18
+ }.freeze
19
19
 
20
- LEVEL = LEVELS[:none]
20
+ LEVEL = LEVELS[:none]
21
21
 
22
- # @return [String] 呼び出し位置
23
- attr_reader :location
22
+ # @return [String] 呼び出し位置
23
+ attr_reader :location
24
24
 
25
- def initialize(location:)
26
- @location = location
27
- end
25
+ def initialize(location:)
26
+ @location = location
27
+ end
28
28
 
29
- #
30
- # DEBUGレベルの標準出力を行う
31
- #
32
- # @param [String] messages メッセージ
33
- #
34
- def debug(*messages)
35
- return if LEVEL < LEVELS[:debug]
29
+ #
30
+ # DEBUGレベルの標準出力を行う
31
+ #
32
+ # @param [String] messages メッセージ
33
+ #
34
+ def debug(*messages)
35
+ return if LEVEL < LEVELS[:debug]
36
36
 
37
- output('DEBUG', *messages)
38
- end
37
+ output('DEBUG', *messages)
38
+ end
39
39
 
40
- #
41
- # INFOレベルの標準出力を行う
42
- #
43
- # @param [String] messages メッセージ
44
- #
45
- def info(*messages)
46
- return if LEVEL < LEVELS[:info]
40
+ #
41
+ # INFOレベルの標準出力を行う
42
+ #
43
+ # @param [String] messages メッセージ
44
+ #
45
+ def info(*messages)
46
+ return if LEVEL < LEVELS[:info]
47
47
 
48
- output('INFO', *messages)
49
- end
48
+ output('INFO', *messages)
49
+ end
50
50
 
51
- private
51
+ private
52
52
 
53
- #
54
- # 標準出力を行う
55
- #
56
- # @param [String] level ログレベル
57
- # @param [String] messages メッセージ
58
- #
59
- def output(level, *messages)
60
- messages.each do |message|
61
- # :#{Thread.current.backtrace[5]}
62
- p "[#{level}] #{@location}: #{message}"
53
+ #
54
+ # 標準出力を行う
55
+ #
56
+ # @param [String] level ログレベル
57
+ # @param [String] messages メッセージ
58
+ #
59
+ def output(level, *messages)
60
+ messages.each do |message|
61
+ # :#{Thread.current.backtrace[5]}
62
+ p "[#{level}] #{@location}: #{message}"
63
+ end
63
64
  end
64
65
  end
65
66
  end