Sha256: df99287a808eef38d56b9cb7be8d622ed9c409c951f09a6c61af1032cb95a09c

Contents?: true

Size: 547 Bytes

Versions: 7

Compression:

Stored size: 547 Bytes

Contents

module PunchingBag
  require 'punching_bag/engine' if defined?(Rails)
  require 'punching_bag/acts_as_punchable'
  require 'voight_kampff'

  def self.punch(punchable, request=nil)
    if request.try(:bot?)
      false
    else
      p = Punch.new
      p.punchable = punchable
      p.save ? p : false
    end
  end

  def self.average_time(*punches)
    total_time = 0
    hits = 0
    punches.each do |punch|
      total_time += punch.average_time.to_f * punch.hits
      hits += punch.hits
    end
    Time.zone.at(total_time / hits)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
punching_bag-0.4.0 lib/punching_bag.rb
punching_bag-0.3.9 lib/punching_bag.rb
punching_bag-0.3.8 lib/punching_bag.rb
punching_bag-0.3.7 lib/punching_bag.rb
punching_bag-0.3.6 lib/punching_bag.rb
punching_bag-0.3.5 lib/punching_bag.rb
punching_bag-0.3.4 lib/punching_bag.rb