Skip to content

Commit 2f22e82

Browse files
author
coding-chimp
committed
Adds method to convert device type to integer
1 parent c02c91c commit 2f22e82

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

lib/onesignal.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ module OneSignal
1616
DEVICE_TYPES = %w(
1717
ios android amazon mpns chrome_app chrome_website wns safari firefox
1818
).freeze
19+
20+
def self.device_type_as_integer(device_type)
21+
DEVICE_TYPES.index(device_type)
22+
end
1923
end

test/onesignal_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require_relative 'test_helper'
2+
3+
class OneSignalTest < Minitest::Test
4+
def test_device_type_as_integer
5+
assert_equal 0, OneSignal.device_type_as_integer('ios')
6+
end
7+
end

0 commit comments

Comments
 (0)