Module: Apifreaks::Internal::Types::Enum
- Includes:
- Type
- Included in:
- Types::AirQualityRequestFormat, Types::AirQualityRequestPrecision, Types::AsnWhoisLookupRequestFormat, Types::AstronomyLookupRequestFormat, Types::BulkCurrentWeatherRequestFormat, Types::BulkDomainAvailabilityCheckRequestFormat, Types::BulkDomainAvailabilityCheckRequestSource, Types::BulkDomainDNSLookupRequestFormat, Types::BulkDomainDNSLookupResponseBulkDNSInfoItemDNSRecordsItemAddressDNSType, Types::BulkDomainDNSLookupResponseBulkDNSInfoItemDNSRecordsItemAdminDNSType, Types::BulkDomainDNSLookupResponseBulkDNSInfoItemDNSRecordsItemOneDNSType, Types::BulkDomainDNSLookupResponseBulkDNSInfoItemDNSRecordsItemPriorityDNSType, Types::BulkDomainDNSLookupResponseBulkDNSInfoItemDNSRecordsItemSingleNameDNSType, Types::BulkDomainDNSLookupResponseBulkDNSInfoItemDNSRecordsItemStringsDNSType, Types::BulkDomainWhoisLookupRequestFormat, Types::BulkDomainWhoisLookupResponseBulkWhoisResponseItemDomainRegistered, Types::BulkDomainWhoisLookupResponseBulkWhoisResponseItemRegistryDataDomainRegistered, Types::BulkEmailValidateRequestFormat, Types::BulkEmailValidateResponseEmailValidationResponsesItemValidEmail, Types::BulkGeolocationLookupRequestFormat, Types::BulkIPSecurityLookupRequestFormat, Types::BulkPhoneValidateRequestFormat, Types::BulkPhoneValidateResponseItemLineType, Types::BulkScreenshotCaptureRequestFormat, Types::BulkUserAgentLookupRequestFormat, Types::BulkVatRateByCountryRequestFormat, Types::BulkZipcodeLookupRequestFormat, Types::CommodityFluctuationRequestFormat, Types::CommodityHistoricalRatesRequestFormat, Types::CommodityLatestRatesRequestFormat, Types::CommodityLatestRatesRequestUpdates, Types::CommoditySymbolsRequestFormat, Types::CommoditySymbolsResponseSymbolsItemUpdateInterval, Types::CommodityTimeSeriesRequestFormat, Types::CurrencyConvertByIPRequestFormat, Types::CurrencyConvertByIPRequestUpdates, Types::CurrencyConvertHistoricalRequestFormat, Types::CurrencyConvertLatestRequestFormat, Types::CurrencyConvertLatestRequestUpdates, Types::CurrencyFluctuationRequestFormat, Types::CurrencyHistoricalLimitsRequestFormat, Types::CurrencyHistoricalRatesRequestFormat, Types::CurrencyLatestRatesRequestFormat, Types::CurrencyLatestRatesRequestUpdates, Types::CurrencySupportedRequestFormat, Types::CurrencySupportedResponseSupportedCurrenciesMapValueStatus, Types::CurrencySymbolsRequestFormat, Types::CurrencyTimeSeriesRequestFormat, Types::CurrentWeatherRequestFormat, Types::DomainAvailabilityCheckRequestFormat, Types::DomainAvailabilityCheckRequestSource, Types::DomainAvailabilitySuggestionsRequestFormat, Types::DomainAvailabilitySuggestionsRequestSource, Types::DomainDNSHistoryRequestFormat, Types::DomainDNSHistoryResponseHistoricalDNSRecordsItemDNSRecordsItemAddressDNSType, Types::DomainDNSHistoryResponseHistoricalDNSRecordsItemDNSRecordsItemAdminDNSType, Types::DomainDNSHistoryResponseHistoricalDNSRecordsItemDNSRecordsItemOneDNSType, Types::DomainDNSHistoryResponseHistoricalDNSRecordsItemDNSRecordsItemPriorityDNSType, Types::DomainDNSHistoryResponseHistoricalDNSRecordsItemDNSRecordsItemSingleNameDNSType, Types::DomainDNSHistoryResponseHistoricalDNSRecordsItemDNSRecordsItemStringsDNSType, Types::DomainDNSLookupRequestFormat, Types::DomainDNSLookupResponseDNSRecordsItemAddressDNSType, Types::DomainDNSLookupResponseDNSRecordsItemAdminDNSType, Types::DomainDNSLookupResponseDNSRecordsItemOneDNSType, Types::DomainDNSLookupResponseDNSRecordsItemPriorityDNSType, Types::DomainDNSLookupResponseDNSRecordsItemSingleNameDNSType, Types::DomainDNSLookupResponseDNSRecordsItemStringsDNSType, Types::DomainDNSReverseRequestFormat, Types::DomainDNSReverseRequestType, Types::DomainDNSReverseResponseReverseDNSRecordsItemDNSRecordsItemAddressDNSType, Types::DomainDNSReverseResponseReverseDNSRecordsItemDNSRecordsItemAdminDNSType, Types::DomainDNSReverseResponseReverseDNSRecordsItemDNSRecordsItemOneDNSType, Types::DomainDNSReverseResponseReverseDNSRecordsItemDNSRecordsItemPriorityDNSType, Types::DomainDNSReverseResponseReverseDNSRecordsItemDNSRecordsItemSingleNameDNSType, Types::DomainDNSReverseResponseReverseDNSRecordsItemDNSRecordsItemStringsDNSType, Types::DomainSslChainLookupRequestFormat, Types::DomainSslLookupRequestFormat, Types::DomainWhoisHistoryRequestFormat, Types::DomainWhoisHistoryResponseWhois, Types::DomainWhoisHistoryResponseWhoisDomainsHistoricalItemDomainRegistered, Types::DomainWhoisHistoryResponseWhoisDomainsHistoricalItemRegistryDataDomainRegistered, Types::DomainWhoisLookupRequestFormat, Types::DomainWhoisLookupResponseDomainRegistered, Types::DomainWhoisLookupResponseRegistryDataDomainRegistered, Types::DomainWhoisReverseRequestFormat, Types::DomainWhoisReverseRequestMode, Types::DomainWhoisReverseResponseWhoisDomainsHistoricalItemAdministrativeContactDomainRegistered, Types::DomainWhoisReverseResponseWhoisDomainsHistoricalItemAdministrativeContactRegistryDataDomainRegistered, Types::EmailValidateRequestFormat, Types::EmailValidateResponseValidEmail, Types::FloodForecastRequestFormat, Types::FloodForecastRequestPrecision, Types::GeocoderReverseRequestFormat, Types::GeocoderSearchRequestFormat, Types::GeolocationLookupRequestFormat, Types::GeolocationLookupRequestLang, Types::GetAdminLevelsRequestFormat, Types::GetAdminUnitDetailsRequestFormat, Types::GetAdminUnitsRequestFormat, Types::GetCitiesRequestFormat, Types::GetCountriesRequestFormat, Types::GetCountryDetailsRequestFormat, Types::GetFlagsRequestFormat, Types::GetFlagsRequestShape, Types::GetFlagsRequestSize, Types::GetFlagsRequestType, Types::GetRegionsRequestFormat, Types::GetSubregionsRequestFormat, Types::HistoricalWeatherRequestFormat, Types::HistoricalWeatherRequestPrecision, Types::IPSecurityLookupRequestFormat, Types::IPWhoisLookupRequestFormat, Types::IbanValidateRequestFormat, Types::MarineWeatherRequestFormat, Types::MarineWeatherRequestPrecision, Types::OcrPredictRequestModel, Types::PdfCompressRequestCompressionLevel, Types::PdfCompressRequestFormat, Types::PdfConvertToBmpRequestFormat, Types::PdfConvertToBmpRequestProfile, Types::PdfConvertToGifRequestFormat, Types::PdfConvertToGifRequestProfile, Types::PdfConvertToJpgRequestFormat, Types::PdfConvertToJpgRequestProfile, Types::PdfConvertToPngRequestFormat, Types::PdfConvertToPngRequestProfile, Types::PdfConvertToTiffRequestFormat, Types::PdfConvertToTiffRequestProfile, Types::PdfDecryptRequestFormat, Types::PdfDeleteFileRequestFormat, Types::PdfDownloadResourceRequestFormat, Types::PdfEncryptRequestFormat, Types::PdfExtractPagesRequestFormat, Types::PdfGetFileStatusRequestFormat, Types::PdfGetTaskStatusRequestFormat, Types::PdfLinearizeRequestFormat, Types::PdfListFilesRequestFormat, Types::PdfMergeRequestFormat, Types::PdfRemovePagesRequestFormat, Types::PdfRestrictRequestFormat, Types::PdfRestrictRequestRestrictionsItem, Types::PdfRotateRequestFormat, Types::PdfSplitRequestFormat, Types::PdfUnrestrictRequestFormat, Types::PdfUploadBinaryRequestFormat, Types::PdfUploadResourcesRequestFormat, Types::PhoneValidateRequestFormat, Types::PhoneValidateResponseLineType, Types::ReadabilityScoreRequestTarget, Types::ReadabilityScoreResponseSentenceReadabilityItemReadabilityLevel, Types::ScreenshotCaptureRequestFileType, Types::ScreenshotCaptureRequestOutput, Types::ScreenshotCaptureRequestScrollSpeed, Types::ScreenshotCaptureRequestWaitForEvent, Types::SubdomainsLookupRequestFormat, Types::SubdomainsLookupRequestStatus, Types::SwiftCodeFindRequestFormat, Types::SwiftCodeLookupRequestFormat, Types::TimezoneConvertRequestFormat, Types::TimezoneLookupRequestFormat, Types::TimezoneLookupRequestLang, Types::UserAgentLookupRequestFormat, Types::VatRateByCountryRequestFormat, Types::VatRateByIPRequestFormat, Types::VatSupportedCountriesRequestFormat, Types::VatSupportedCountriesRequestType, Types::VatValidateRequestFormat, Types::WeatherForecastRequestFormat, Types::WeatherForecastRequestPrecision, Types::WeatherTimeSeriesRequestFormat, Types::WeatherTimeSeriesRequestPrecision, Types::WebScrapeRequestBodyBlockURLInstructionsItemGeneralImageCaptchaGeneralImageCaptchaItemModel, Types::WebScrapeRequestFormat, Types::ZipcodeDistanceMatchRequestFormat, Types::ZipcodeDistanceMatchRequestUnit, Types::ZipcodeDistanceRequestFormat, Types::ZipcodeDistanceRequestUnit, Types::ZipcodeLookupRequestFormat, Types::ZipcodeSearchByCityRequestFormat, Types::ZipcodeSearchByRadiusRequestFormat, Types::ZipcodeSearchByRadiusRequestUnit, Types::ZipcodeSearchByRegionRequestFormat
- Defined in:
- lib/apifreaks/internal/types/enum.rb
Overview
Module for defining enums
Instance Method Summary collapse
- #coerce(value, strict: strict?) ) ⇒ Object
- #finalize! ⇒ Object private
- #inspect ⇒ Object
-
#load(str) ⇒ String
Parse JSON string and coerce to the enum value.
- #strict! ⇒ Object private
- #strict? ⇒ Boolean private
- #values ⇒ Array<Object> private
Methods included from JSON::Serializable
Instance Method Details
#coerce(value, strict: strict?) ) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/apifreaks/internal/types/enum.rb', line 32 def coerce(value, strict: strict?) coerced_value = Utils.coerce(Symbol, value) return coerced_value if values.include?(coerced_value) raise Errors::TypeError, "`#{value}` not in enum #{self}" if strict value end |
#finalize! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/apifreaks/internal/types/enum.rb', line 18 def finalize! values end |
#inspect ⇒ Object
50 51 52 |
# File 'lib/apifreaks/internal/types/enum.rb', line 50 def inspect "#{name}[#{values.join(", ")}]" end |
#load(str) ⇒ String
Parse JSON string and coerce to the enum value
46 47 48 |
# File 'lib/apifreaks/internal/types/enum.rb', line 46 def load(str) coerce(::JSON.parse(str)) end |
#strict! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/apifreaks/internal/types/enum.rb', line 28 def strict! @strict = true end |
#strict? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/apifreaks/internal/types/enum.rb', line 23 def strict? @strict ||= false end |
#values ⇒ Array<Object>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/apifreaks/internal/types/enum.rb', line 13 def values @values ||= constants.map { |c| const_get(c) } end |