Class: VivlioStarter::CLI::IndexCommands::TermSpread::Entry

Inherits:
Data
  • Object
show all
Defined in:
lib/vivlio_starter/cli/index/term_spread.rb

Overview

語の広がり。ratio は「出現章数 / 全章数」。

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#chapter_countObject (readonly)

Returns the value of attribute chapter_count

Returns:

  • (Object)

    the current value of chapter_count



45
46
47
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 45

def chapter_count
  @chapter_count
end

#termObject (readonly)

Returns the value of attribute term

Returns:

  • (Object)

    the current value of term



45
46
47
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 45

def term
  @term
end

#total_chaptersObject (readonly)

Returns the value of attribute total_chapters

Returns:

  • (Object)

    the current value of 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

#percentageObject



48
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 48

def percentage = (ratio * 100).round

#ratioObject



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_sObject



50
# File 'lib/vivlio_starter/cli/index/term_spread.rb', line 50

def to_s = "#{chapter_count}/#{total_chapters} 章(#{percentage}%)"