Class: Vivlio::Starter::CLI::Metrics::WarningChecker
- Inherits:
-
Object
- Object
- Vivlio::Starter::CLI::Metrics::WarningChecker
- Defined in:
- lib/vivlio/starter/cli/metrics/formatter.rb
Overview
章・節の警告判定
Instance Method Summary collapse
-
#chapter_warning(chapter_num, chars) ⇒ Object
章の警告を判定する.
- #excluded_chapter?(chapter_num) ⇒ Boolean
-
#has_warning?(chapter_num, chars, sections) ⇒ Boolean
警告がある章かどうか.
-
#initialize(config_loader) ⇒ WarningChecker
constructor
A new instance of WarningChecker.
-
#section_warning(chars, chapter_num: nil) ⇒ Object
節の警告を判定する.
Constructor Details
#initialize(config_loader) ⇒ WarningChecker
Returns a new instance of WarningChecker.
241 242 243 244 245 |
# File 'lib/vivlio/starter/cli/metrics/formatter.rb', line 241 def initialize(config_loader) @thresholds = config_loader.volume_thresholds @labels = config_loader.labels @exclude = config_loader.exclude_chapters end |
Instance Method Details
#chapter_warning(chapter_num, chars) ⇒ Object
章の警告を判定する
248 249 250 251 252 |
# File 'lib/vivlio/starter/cli/metrics/formatter.rb', line 248 def chapter_warning(chapter_num, chars) return nil if excluded?(chapter_num) check_volume(chars, thresholds[:chapter]) end |
#excluded_chapter?(chapter_num) ⇒ Boolean
268 269 270 |
# File 'lib/vivlio/starter/cli/metrics/formatter.rb', line 268 def excluded_chapter?(chapter_num) excluded?(chapter_num) end |
#has_warning?(chapter_num, chars, sections) ⇒ Boolean
警告がある章かどうか
262 263 264 265 266 |
# File 'lib/vivlio/starter/cli/metrics/formatter.rb', line 262 def has_warning?(chapter_num, chars, sections) return true if chapter_warning(chapter_num, chars) sections.any? { section_warning(it.chars, chapter_num:) } end |
#section_warning(chars, chapter_num: nil) ⇒ Object
節の警告を判定する
255 256 257 258 259 |
# File 'lib/vivlio/starter/cli/metrics/formatter.rb', line 255 def section_warning(chars, chapter_num: nil) return nil if excluded?(chapter_num) check_volume(chars, thresholds[:section]) end |