Sha256: c56322ad6d5c1f8609264fc835554c213e5f6feeebe4d070df5495564899415e

Contents?: true

Size: 386 Bytes

Versions: 22

Compression:

Stored size: 386 Bytes

Contents

class Infobar::Trend
  def initialize(values, symbols: %i[ ↘ → ↗ ])
    @values  = values
    @symbols = symbols
    @string  = arrow
  end

  def to_s
    @string
  end

  private

  def arrow
    lr = MoreMath::LinearRegression.new(@values)
    case
    when lr.slope_zero?
      @symbols[1]
    when lr.a > 0
      @symbols[2]
    else
      @symbols[0]
    end.to_s
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
infobar-0.8.1 lib/infobar/trend.rb
infobar-0.8.0 lib/infobar/trend.rb
infobar-0.7.4 lib/infobar/trend.rb
infobar-0.7.2 lib/infobar/trend.rb
infobar-0.7.1 lib/infobar/trend.rb
infobar-0.7.0 lib/infobar/trend.rb
infobar-0.6.2 lib/infobar/trend.rb
infobar-0.6.1 lib/infobar/trend.rb
infobar-0.6.0 lib/infobar/trend.rb
infobar-0.5.1 lib/infobar/trend.rb
infobar-0.5.0 lib/infobar/trend.rb
infobar-0.4.0 lib/infobar/trend.rb
infobar-0.3.0 lib/infobar/trend.rb
infobar-0.2.0 lib/infobar/trend.rb
infobar-0.1.1 lib/infobar/trend.rb
infobar-0.1.0 lib/infobar/trend.rb
infobar-0.0.7 lib/infobar/trend.rb
infobar-0.0.6 lib/infobar/trend.rb
infobar-0.0.5 lib/infobar/trend.rb
infobar-0.0.4 lib/infobar/trend.rb