-
Notifications
You must be signed in to change notification settings - Fork 4
Add residential proxy data to anonymizer object #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'date' | ||
| require 'maxmind/geoip2/record/abstract' | ||
|
|
||
| module MaxMind | ||
| module GeoIP2 | ||
| module Record | ||
| # Contains data from an anonymizer data feed, such as the residential | ||
| # proxy feed. | ||
| # | ||
| # This record is returned by the anonymizer object of the Insights web | ||
| # service. | ||
| class AnonymizerFeed < Abstract | ||
| # A score ranging from 1 to 99 that represents our percent confidence | ||
| # that the network is currently part of this anonymizer feed. This | ||
| # property is only available from Insights. | ||
| # | ||
| # @return [Integer, nil] | ||
| def confidence | ||
| get('confidence') | ||
| end | ||
|
|
||
| # The last day that the network was sighted in this anonymizer feed. | ||
| # This value is parsed lazily. This property is only available from | ||
| # Insights. | ||
| # | ||
| # @return [Date, nil] A Date object representing the last seen date, | ||
| # or nil if the date is not available. | ||
| def network_last_seen | ||
| return @network_last_seen if defined?(@network_last_seen) | ||
|
|
||
| date_string = get('network_last_seen') | ||
|
|
||
| if !date_string | ||
| return nil | ||
| end | ||
|
|
||
| @network_last_seen = Date.parse(date_string) | ||
| end | ||
|
Comment on lines
+30
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Ruby, We can optimize this and make it more idiomatic by assigning the result of the ternary operator directly to def network_last_seen
return @network_last_seen if defined?(@network_last_seen)
date_string = get('network_last_seen')
@network_last_seen = date_string ? Date.parse(date_string) : nil
end |
||
|
|
||
| # The name of the provider associated with the network in this | ||
| # anonymizer feed. This property is only available from Insights. | ||
| # | ||
| # @return [String, nil] | ||
| def provider_name | ||
| get('provider_name') | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this project requires Ruby 3.2+, we can use the safe navigation operator (
&.) to safely access'residential'onrecordif it is not nil. This is much more idiomatic and concise than the ternary operator check.