Module: LinkIO::Platform
- Defined in:
- lib/linkio/platform.rb
Overview
Platform detection for incoming requests. Mirrors the Platform enum from
the Node.js LinkIO backend.
Constant Summary collapse
- IOS =
"ios"- ANDROID =
"android"- WEB =
"web"- UNKNOWN =
"unknown"- ALL =
[IOS, ANDROID, WEB, UNKNOWN].freeze
- IOS_PATTERN =
/iphone|ipad|ipod|ios/i- ANDROID_PATTERN =
/android/i
Class Method Summary collapse
-
.detect(user_agent) ⇒ String
Detect the platform from a User-Agent string.
Class Method Details
.detect(user_agent) ⇒ String
Detect the platform from a User-Agent string.
23 24 25 26 27 28 29 |
# File 'lib/linkio/platform.rb', line 23 def detect(user_agent) ua = user_agent.to_s return IOS if ua.match?(IOS_PATTERN) return ANDROID if ua.match?(ANDROID_PATTERN) WEB end |