Class: VivlioStarter::CLI::IndexCommands::IndexSizeEstimator::Estimate

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

Overview

算出結果。range は目安語数の幅(整数指定なら 1 点の範囲になる)。

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#charsObject (readonly)

Returns the value of attribute chars

Returns:

  • (Object)

    the current value of chars



56
57
58
# File 'lib/vivlio_starter/cli/index/index_size_estimator.rb', line 56

def chars
  @chars
end

#presetObject (readonly)

Returns the value of attribute preset

Returns:

  • (Object)

    the current value of preset



56
57
58
# File 'lib/vivlio_starter/cli/index/index_size_estimator.rb', line 56

def preset
  @preset
end

#rangeObject (readonly)

Returns the value of attribute range

Returns:

  • (Object)

    the current value of range



56
57
58
# File 'lib/vivlio_starter/cli/index/index_size_estimator.rb', line 56

def range
  @range
end

Instance Method Details

#chars_per_term_rangeObject

「約 N 字に 1 語」。著者は密度で考えるので、語数と密度を併記するための値。 語数が多いほど 1 語あたりの字数は小さくなるので、上下が入れ替わる。



59
60
61
62
63
# File 'lib/vivlio_starter/cli/index/index_size_estimator.rb', line 59

def chars_per_term_range
  return (0..0) if range.end.zero?

  ((chars / range.end)..(chars / [range.begin, 1].max))
end

#to_sObject



65
# File 'lib/vivlio_starter/cli/index/index_size_estimator.rb', line 65

def to_s = range.begin == range.end ? "#{range.begin}" : "#{range.begin}#{range.end}"