class Macrocosm::Links

Constants

CurvenessRange
MaxCurveness

Public Class Methods

new() click to toggle source
# File lib/macrocosm.rb, line 13
def initialize
  @links = []
  @links_on_same_ends = Hash.new{ |h, k| h[k] = 0 }
  @last_curveness = Hash.new{ |h, k| h[k] = MaxCurveness.dup }
end

Public Instance Methods

calc_curveness(link) click to toggle source
# File lib/macrocosm.rb, line 43
def calc_curveness(link)
  ends = link[:ends]
  count = @links_on_same_ends[ends]
  return 0 if count == 0
  step = (CurvenessRange / count).round(2)
  @last_curveness[ends] -= step
end