Sha256: 5452a0fab72a1d0d7b5d4a5add8efc9702c6ea8690671329a98fb61e7b351b10

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'socket'
require 'oj'

module DevCycle
  class PlatformData
    attr_accessor :deviceModel, :platformVersion, :sdkVersion, :sdkType, :platform, :hostname

    def initialize(sdk_type = nil, sdk_version = nil, platform_version = nil, device_model = nil, platform = nil, hostname = nil)
      @sdkType = sdk_type
      @sdkVersion = sdk_version
      @platformVersion = platform_version
      @deviceModel = device_model
      @platform = platform
      @hostname = hostname
    end

    def default
      @sdkType = 'server'
      @sdkVersion = VERSION
      @platformVersion = RUBY_VERSION
      @deviceModel = nil
      @platform = 'Ruby'
      @hostname = Socket.gethostname
      self
    end

    def to_hash
      {
        sdkType: @sdkType,
        sdkVersion: @sdkVersion,
        platformVersion: @platformVersion,
        deviceModel: @deviceModel,
        platform: @platform,
        hostname: @hostname
      }
    end

    def to_json
      Oj.dump(to_hash, mode: :json)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
devcycle-ruby-server-sdk-3.2.0 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-3.1.0 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-3.0.0 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.7.1 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.6.3 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.6.2 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.6.1 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.6.0 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.5.0 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.4.1 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.4.0 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.3.5 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.3.4 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.3.3 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.3.2 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.3.1 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.3.0 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.2.1 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb
devcycle-ruby-server-sdk-2.2.0 lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb