class Type

Serializable type

Attributes

type[R]

Public Class Methods

new(type) click to toggle source

Instantiate a Type

@example Instantiate a Type

type = Type.new('int')
# File lib/steamd/generator/ruby/serializable_type.rb, line 10
def initialize(type)
  @type = type
end

Public Instance Methods

bytedirective() click to toggle source

The byte directive for this type

@return [String]

# File lib/steamd/generator/ruby/serializable_type.rb, line 48
def bytedirective
  {
    'int' => 'l<',
    'ushort' => 'S<',
    'short' => 's<',
    'byte' => 'c',
    'uint' => 'L<',
    'ulong' => 'Q<'
  }[type]
end
bytesize() click to toggle source

The size in bytes of this type

@return [Integer]

# File lib/steamd/generator/ruby/serializable_type.rb, line 62
def bytesize
  case type
  when 'uint', 'int'
    4
  when 'ushort', 'short'
    2
  when 'ulong', 'long'
    8
  when 'byte'
    1
  end
end
encodable?() click to toggle source

Is this type an encodable type?

@return [Bool]

# File lib/steamd/generator/ruby/serializable_type.rb, line 34
def encodable?
  encodables.include?(type)
end
klass() click to toggle source

The Class represented by this Type

@return [Object]

# File lib/steamd/generator/ruby/serializable_type.rb, line 78
def klass
  type.constantize
end
primitive?() click to toggle source

Is this type an primitive type?

@return [Bool]

# File lib/steamd/generator/ruby/serializable_type.rb, line 41
def primitive?
  primitives.include?(type)
end

Private Instance Methods

encodables() click to toggle source

@api private

# File lib/steamd/generator/ruby/serializable_type.rb, line 90
def encodables
  ['Steamclient::CMsgProtoBufHeader', 'Gc::CMsgProtoBufHeader']
end
primitives() click to toggle source

@api private

# File lib/steamd/generator/ruby/serializable_type.rb, line 85
def primitives
  %w(int short uint long ulong byte ushort)
end