module Plugin::Score

Public Instance Methods

choose_best_score(score_list) click to toggle source

score_list の中から、利用すべきScoreをひとつだけ返す。 一つも該当するものがない場合は nil を返す。複数該当する場合は、結果は不定。

# File core/plugin/score/select.rb, line 24
def choose_best_score(score_list)
  selected = max_score_count(smallest_leading_text_size(score_list))
  selected.first
end
max_score_count(score_list) click to toggle source

Scoreを構成するNoteの数が一番多いもののみを列挙する。

# File core/plugin/score/select.rb, line 35
def max_score_count(score_list)
  max_all(score_list, &:count)
end
score_by_score(model, target_note=model) click to toggle source
# File core/plugin/score/select.rb, line 5
def score_by_score(model, target_note=model)
  @score_cache ||= TimeLimitedStorage.new(Array, Object, 60)
  @score_cache[[model, target_note]] ||= score_by_score_nocache(model, target_note)
end
score_by_score_nocache(model, target_note=model) click to toggle source
# File core/plugin/score/select.rb, line 10
def score_by_score_nocache(model, target_note=model)
  _, _, available_score_list = Plugin.filtering(:score_filter, model, target_note, Set.new)
  selected_score = choose_best_score(available_score_list)
  if selected_score &&  !selected_score.all? { |s| s.is_a?(Plugin::Score::TextNote) }
    score_expand(selected_score, model)
  elsif target_note.is_a?(Plugin::Score::TextNote)
    [target_note]
  else
    score_by_score(model, Plugin::Score::TextNote.new(description: model.description))
  end
end
smallest_leading_text_size(score_list) click to toggle source

最初にTextNote以外が出てくるまでに出てきたTextNoteのdescriptionの文字数の合計が少ないもののみを列挙する。

# File core/plugin/score/select.rb, line 30
def smallest_leading_text_size(score_list)
  min_all(score_list, &method(:leading_text_size))
end