Class: PinPoint::IpBlock

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
lib/pin_point/ip_block.rb

Class Method Summary collapse

Class Method Details

.for_ip(ip) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/pin_point/ip_block.rb', line 22

def for_ip ip
  val = ip_to_int ip
  maybe = where( :range_low.lte => val ).order_by( [[:range_low, :desc]] ).first
  if maybe.try( :range_high ).to_i >= val
    return maybe
  end
  nil
end