Class: VivlioStarter::CLI::IndexCommands::MainReferenceSuggester::Chapter
- Inherits:
-
Data
- Object
- Data
- VivlioStarter::CLI::IndexCommands::MainReferenceSuggester::Chapter
- Defined in:
- lib/vivlio_starter/cli/index/main_reference_suggester.rb
Overview
1 章ぶんの素材
Instance Attribute Summary collapse
-
#basename ⇒ Object
readonly
Returns the value of attribute basename.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headings ⇒ Object
readonly
Returns the value of attribute headings.
Instance Method Summary collapse
Instance Attribute Details
#basename ⇒ Object (readonly)
Returns the value of attribute basename
56 57 58 |
# File 'lib/vivlio_starter/cli/index/main_reference_suggester.rb', line 56 def basename @basename end |
#body ⇒ Object (readonly)
Returns the value of attribute body
56 57 58 |
# File 'lib/vivlio_starter/cli/index/main_reference_suggester.rb', line 56 def body @body end |
#headings ⇒ Object (readonly)
Returns the value of attribute headings
56 57 58 |
# File 'lib/vivlio_starter/cli/index/main_reference_suggester.rb', line 56 def headings @headings end |
Instance Method Details
#number ⇒ Object
64 |
# File 'lib/vivlio_starter/cli/index/main_reference_suggester.rb', line 64 def number = basename[/\A\d+/].to_i |
#score(pattern) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/vivlio_starter/cli/index/main_reference_suggester.rb', line 57 def score(pattern) weighted = HEADING_WEIGHTS.sum do |level, weight| headings.fetch(level, []).count { it.match?(pattern) } * weight end weighted + body.scan(pattern).size end |