Class: StoreIPs
- Inherits:
-
Object
- Object
- StoreIPs
- Defined in:
- lib/ddis/store_ips.rb
Instance Method Summary collapse
- #down_with_dns(ip) ⇒ Object
- #dump ⇒ Object
-
#initialize ⇒ StoreIPs
constructor
A new instance of StoreIPs.
- #save ⇒ Object
- #up_no_dns(ip) ⇒ Object
Constructor Details
#initialize ⇒ StoreIPs
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 |
#dump ⇒ Object
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 |
#save ⇒ Object
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 |