Class: VivlioStarter::CLI::IndexCommands::TermSpread::Entry
- Inherits:
-
Data
- Object
- Data
- VivlioStarter::CLI::IndexCommands::TermSpread::Entry
- Defined in:
- lib/vivlio_starter/cli/index/term_spread.rb
Overview
語の広がり。ratio は「出現章数 / 全章数」。
Instance Attribute Summary collapse
-
#chapter_count ⇒ Object
readonly
Returns the value of attribute chapter_count.
-
#term ⇒ Object
readonly
Returns the value of attribute term.
-
#total_chapters ⇒ Object
readonly
Returns the value of attribute total_chapters.
Instance Method Summary collapse
Instance Attribute Details
#chapter_count ⇒ Object (readonly)
Returns the value of attribute chapter_count
45 46 47 |
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 45 def chapter_count @chapter_count end |
#term ⇒ Object (readonly)
Returns the value of attribute term
45 46 47 |
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 45 def term @term end |
#total_chapters ⇒ Object (readonly)
Returns the value of attribute total_chapters
45 46 47 |
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 45 def total_chapters @total_chapters end |
Instance Method Details
#percentage ⇒ Object
48 |
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 48 def percentage = (ratio * 100).round |
#ratio ⇒ Object
46 |
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 46 def ratio = total_chapters.zero? ? 0.0 : chapter_count.fdiv(total_chapters) |
#to_s ⇒ Object
50 |
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 50 def to_s = "#{chapter_count}/#{total_chapters} 章(#{percentage}%)" |