Module: YandexDetector::Properties
- Included in:
- Result
- Defined in:
- lib/yandex_detector/result/properties.rb
Overview
This module contain YandexDetector::Result instance’s methods, which allow to determine concrete properties of result
Instance Method Summary collapse
-
#android? ⇒ Bool
Android detected.
-
#blackberry? ⇒ Bool
Blackberry detected.
-
#data ⇒ Hash
Hash representation of API service’s answer according to documentation http://api.yandex.ru/detector/doc/dg/concepts/detector-response.xml.
-
#device_class ⇒ String?
Device_class string according to documentation http://api.yandex.ru/detector/doc/dg/concepts/detector-response.xml.
-
#error? ⇒ Bool
Any error occured.
-
#error_message ⇒ String?
Error message if present, or nil otherwise.
-
#iphone? ⇒ Bool
Iphone detected.
-
#request_performed? ⇒ Bool
Network request to API service was performed.
-
#success? ⇒ Bool
No error occured.
-
#text ⇒ String
Text representation of API service’s answer according to documentation http://api.yandex.ru/detector/doc/dg/concepts/detector-response.xml.
Instance Method Details
#android? ⇒ Bool
Returns android detected.
38 39 40 |
# File 'lib/yandex_detector/result/properties.rb', line 38 def android? device_class === 'android' end |
#blackberry? ⇒ Bool
Returns blackberry detected.
43 44 45 |
# File 'lib/yandex_detector/result/properties.rb', line 43 def blackberry? device_class === 'rim' end |
#data ⇒ Hash
Returns Hash representation of API service’s answer according to documentation http://api.yandex.ru/detector/doc/dg/concepts/detector-response.xml. All ‘-’ signs in tag names replaced by ‘_’ and tag names converted to symbols to use as Hash’s keys.
59 60 61 62 63 64 65 |
# File 'lib/yandex_detector/result/properties.rb', line 59 def data begin @data[:data] rescue nil end end |
#device_class ⇒ String?
Returns device_class string according to documentation http://api.yandex.ru/detector/doc/dg/concepts/detector-response.xml.
49 50 51 52 53 54 55 |
# File 'lib/yandex_detector/result/properties.rb', line 49 def device_class begin @data[:data][:yandex_mobile_info][:device_class] rescue nil end end |
#error? ⇒ Bool
Returns any error occured.
13 14 15 |
# File 'lib/yandex_detector/result/properties.rb', line 13 def error? !request_performed? or @data.nil? or !@data[:error].nil? end |
#error_message ⇒ String?
Returns error message if present, or nil otherwise.
18 19 20 21 22 23 24 |
# File 'lib/yandex_detector/result/properties.rb', line 18 def begin @data[:error] rescue nil end end |
#iphone? ⇒ Bool
Returns iphone detected.
33 34 35 |
# File 'lib/yandex_detector/result/properties.rb', line 33 def iphone? device_class === 'iphoneos' end |
#request_performed? ⇒ Bool
Returns network request to API service was performed.
7 8 9 |
# File 'lib/yandex_detector/result/properties.rb', line 7 def request_performed? @request_performed end |
#success? ⇒ Bool
Returns no error occured.
27 28 29 |
# File 'lib/yandex_detector/result/properties.rb', line 27 def success? !error? end |
#text ⇒ String
Returns Text representation of API service’s answer according to documentation http://api.yandex.ru/detector/doc/dg/concepts/detector-response.xml.
68 69 70 71 72 73 74 |
# File 'lib/yandex_detector/result/properties.rb', line 68 def text begin @data[:text] rescue nil end end |