Class: Type
- Inherits:
-
Object
- Object
- Type
- Defined in:
- lib/steamd/generator/ruby/serializable_type.rb
Overview
Serializable type
Instance Attribute Summary collapse
-
#type ⇒ String
readonly
The String representation of the Type.
Instance Method Summary collapse
-
#bytedirective ⇒ String
The byte directive for this type.
-
#bytesize ⇒ Integer
The size in bytes of this type.
-
#encodable? ⇒ Bool
Is this type an encodable type?.
-
#initialize(type) ⇒ Type
constructor
Instantiate a Type.
-
#klass ⇒ Object
The Class represented by this Type.
-
#primitive? ⇒ Bool
Is this type an primitive type?.
Constructor Details
#initialize(type) ⇒ Type
Instantiate a Type
10 11 12 |
# File 'lib/steamd/generator/ruby/serializable_type.rb', line 10 def initialize(type) @type = type end |
Instance Attribute Details
#type ⇒ String (readonly)
The String representation of the Type. If it is a SteamKit Internal type, the type is transformed into namespaces from the ‘steam-proto` repo.
18 19 20 |
# File 'lib/steamd/generator/ruby/serializable_type.rb', line 18 def type @type end |
Instance Method Details
#bytedirective ⇒ String
The byte directive for this type
48 49 50 51 52 53 54 55 56 57 |
# 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 ⇒ Integer
The size in bytes of this type
62 63 64 65 66 67 68 69 70 71 72 73 |
# 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? ⇒ Bool
Is this type an encodable type?
34 35 36 |
# File 'lib/steamd/generator/ruby/serializable_type.rb', line 34 def encodable? encodables.include?(type) end |
#klass ⇒ Object
The Class represented by this Type
78 79 80 |
# File 'lib/steamd/generator/ruby/serializable_type.rb', line 78 def klass type.constantize end |
#primitive? ⇒ Bool
Is this type an primitive type?
41 42 43 |
# File 'lib/steamd/generator/ruby/serializable_type.rb', line 41 def primitive? primitives.include?(type) end |