Skip to content

Commit

Permalink
Optimize repetitive code
Browse files Browse the repository at this point in the history
  • Loading branch information
alaz committed Dec 20, 2016
1 parent 7759274 commit 473b661
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/legitbot/facebook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ class Facebook < BotMatch
client = Irrc::Client.new
client.query :radb, 'AS32934'
results = client.perform
Hash[
:ipv4 => SegmentTree.new(
results[AS][:ipv4][AS].map { |cidr|
[IPAddr.new(cidr).to_range, true]
}),
:ipv6 => SegmentTree.new(
results[AS][:ipv6][AS].map { |cidr|

Hash[%i(ipv4 ipv6).map { |k|
[k, SegmentTree.new(results[AS][k][AS].map { |cidr|
[IPAddr.new(cidr).to_range, true]
})
]
})]
}]
end

def valid?
Expand Down

0 comments on commit 473b661

Please sign in to comment.