Class: StoreIPs

Inherits:
Object
  • Object
show all
Defined in:
lib/ddis/store_ips.rb

Instance Method Summary collapse

Constructor Details

#initializeStoreIPs

Returns a new instance of StoreIPs.



10
11
12
13
14
15
# File 'lib/ddis/store_ips.rb', line 10

def initialize
  @red = Redis.new
  @db  = Date.today.to_s
  @red.sadd "ip.dates", @db
  @red.save
end

Instance Method Details

#down_with_dns(ip) ⇒ Object



22
23
24
25
# File 'lib/ddis/store_ips.rb', line 22

def down_with_dns ip
  @red.srem "ip.#{@db}.up", ip
  @red.sadd "ip.#{@db}.down", ip
end

#dumpObject



27
28
29
30
31
32
33
# File 'lib/ddis/store_ips.rb', line 27

def dump
  0 if @red.sinter "[email protected]", "[email protected]"
  { 
    :up    => @red.smembers( "ip.#{@db}.up" ), 
    :down  => @red.smembers( "ip.#{@db}.down" ), 
  }
end

#saveObject



35
36
37
# File 'lib/ddis/store_ips.rb', line 35

def save
  @red.save
end

#up_no_dns(ip) ⇒ Object



17
18
19
20
# File 'lib/ddis/store_ips.rb', line 17

def up_no_dns ip
  @red.srem "ip.#{@db}.down", ip
  @red.sadd "ip.#{@db}.up", ip
end