Module: NyanCatFormat::Wide

Defined in:
lib/nyan_cat_format/wide.rb

Instance Method Summary collapse

Instance Method Details

#example_width(example = current) ⇒ Object



4
5
6
# File 'lib/nyan_cat_format/wide.rb', line 4

def example_width(example = current)
  net_width_for(example) - net_width_for(example - 1)
end

#net_width_for(example) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/nyan_cat_format/wide.rb', line 8

def net_width_for(example)
  @net_width ||= {}

  @net_width[example] ||= begin
    return 0 if example < 0
    net_width = terminal_width - padding_width - cat_length
    rough_example_width = (net_width * example.to_f / @example_count.to_f)
    rough_example_width.round
  end
end