1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
require 'geocoder/results/base'
module Geocoder::Result
class Ipregistry < Base
def initialize(data)
super
@data = flatten_hash(data)
end
def coordinates
[@data['location_latitude'], @data['location_longitude']]
end
def flatten_hash(hash)
hash.each_with_object({}) do |(k, v), h|
if v.is_a? Hash
flatten_hash(v).map do |h_k, h_v|
h["#{k}_#{h_k}".to_s] = h_v
end
else
h[k] = v
end
end
end
private :flatten_hash
def city
@data['location_city']
end
def country
@data['location_country_name']
end
def country_code
@data['location_country_code']
end
def postal_code
@data['location_postal']
end
def state
@data['location_region_name']
end
def state_code
@data['location_region_code']
end
# methods for fields specific to Ipregistry
def ip
@data["ip"]
end
def type
@data["type"]
end
def hostname
@data["hostname"]
end
def carrier_name
@data["carrier_name"]
end
def carrier_mcc
@data["carrier_mcc"]
end
def carrier_mnc
@data["carrier_mnc"]
end
def connection_asn
@data["connection_asn"]
end
def connection_domain
@data["connection_domain"]
end
def connection_organization
@data["connection_organization"]
end
def connection_type
@data["connection_type"]
end
def currency_code
@data["currency_code"]
end
def currency_name
@data["currency_name"]
end
def currency_plural
@data["currency_plural"]
end
def currency_symbol
@data["currency_symbol"]
end
def currency_symbol_native
@data["currency_symbol_native"]
end
def currency_format_negative_prefix
@data["currency_format_negative_prefix"]
end
def currency_format_negative_suffix
@data["currency_format_negative_suffix"]
end
def currency_format_positive_prefix
@data["currency_format_positive_prefix"]
end
def currency_format_positive_suffix
@data["currency_format_positive_suffix"]
end
def location_continent_code
@data["location_continent_code"]
end
def location_continent_name
@data["location_continent_name"]
end
def location_country_area
@data["location_country_area"]
end
def location_country_borders
@data["location_country_borders"]
end
def location_country_calling_code
@data["location_country_calling_code"]
end
def location_country_capital
@data["location_country_capital"]
end
def location_country_code
@data["location_country_code"]
end
def location_country_name
@data["location_country_name"]
end
def location_country_population
@data["location_country_population"]
end
def location_country_population_density
@data["location_country_population_density"]
end
def location_country_flag_emoji
@data["location_country_flag_emoji"]
end
def location_country_flag_emoji_unicode
@data["location_country_flag_emoji_unicode"]
end
def location_country_flag_emojitwo
@data["location_country_flag_emojitwo"]
end
def location_country_flag_noto
@data["location_country_flag_noto"]
end
def location_country_flag_twemoji
@data["location_country_flag_twemoji"]
end
def location_country_flag_wikimedia
@data["location_country_flag_wikimedia"]
end
def location_country_languages
@data["location_country_languages"]
end
def location_country_tld
@data["location_country_tld"]
end
def location_region_code
@data["location_region_code"]
end
def location_region_name
@data["location_region_name"]
end
def location_city
@data["location_city"]
end
def location_postal
@data["location_postal"]
end
def location_latitude
@data["location_latitude"]
end
def location_longitude
@data["location_longitude"]
end
def location_language_code
@data["location_language_code"]
end
def location_language_name
@data["location_language_name"]
end
def location_language_native
@data["location_language_native"]
end
def location_in_eu
@data["location_in_eu"]
end
def security_is_bogon
@data["security_is_bogon"]
end
def security_is_cloud_provider
@data["security_is_cloud_provider"]
end
def security_is_tor
@data["security_is_tor"]
end
def security_is_tor_exit
@data["security_is_tor_exit"]
end
def security_is_proxy
@data["security_is_proxy"]
end
def security_is_anonymous
@data["security_is_anonymous"]
end
def security_is_abuser
@data["security_is_abuser"]
end
def security_is_attacker
@data["security_is_attacker"]
end
def security_is_threat
@data["security_is_threat"]
end
def time_zone_id
@data["time_zone_id"]
end
def time_zone_abbreviation
@data["time_zone_abbreviation"]
end
def time_zone_current_time
@data["time_zone_current_time"]
end
def time_zone_name
@data["time_zone_name"]
end
def time_zone_offset
@data["time_zone_offset"]
end
def time_zone_in_daylight_saving
@data["time_zone_in_daylight_saving"]
end
end
end
|