Class: Variable

Inherits:
Node
  • Object
show all
Defined in:
lib/steamd/nodes/variable_node.rb

Overview

Base variable, each variable has a type and a name at the very least.

Direct Known Subclasses

VariableWithModifier, VariableWithValue

Instance Method Summary collapse

Instance Method Details

#nameString

Returns the name of the variable

Returns:

  • (String)

    the variable name



7
8
9
# File 'lib/steamd/nodes/variable_node.rb', line 7

def name
  variable_name.text_value
end

#sizeString/Integer/nil

Returns the size, if any of the variable. ie byte<6> y;

Returns:

  • (String/Integer/nil)

    the variable size



21
22
23
24
25
26
27
28
29
# File 'lib/steamd/nodes/variable_node.rb', line 21

def size
  return nil unless var_type && var_type.respond_to?(:size)

  if var_type.size.text_value.empty?
    nil
  else
    var_type.size.var_value.value
  end
end

#to_hashHash

Hash representation of this Variable Node

Returns:

  • (Hash)


34
35
36
37
38
39
40
41
42
43
# File 'lib/steamd/nodes/variable_node.rb', line 34

def to_hash
  {
    name: name,
    type: type,
    modifier: nil,
    value: nil,
    size: size,
    modifier_size: nil
  }
end

#typeString

Returns the type of the variable

Returns:

  • (String)

    the variable type



14
15
16
# File 'lib/steamd/nodes/variable_node.rb', line 14

def type
  var_type.type.text_value
end