Class: RuntimeInspection::State

Inherits:
Hash
  • Object
show all
Defined in:
lib/rti/state.rb

Overview

Data managed about each TCP connection. Note that these values can be manged from the remote session (e.g. by issuing commands like state.use_yaml = true).

Instance Method Summary collapse

Constructor Details

#initialize(socket = Thread.current[:socket], cmd_count = 1, block_count = 0, block_cmd = '', use_yaml = false, safe_level = 3) ⇒ State

Create a new object for tracking state information.

socket

The owner connection for this data.

cmd_count

The current evaluation number.

block_count

The current block number. When bigger than zero, multiple lines are collected until a blank line is encountered and then the entire block is evaluated. Each successive block will increase the number (similar to the normal cmd_count value).

block_cmd

The collection of the block if the block_count is larger than zero.

use_yaml

The output should be YAML.

safe_level

The level $SAFE is declared at for each evaluation.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rti/state.rb', line 38

def initialize( socket=Thread.current[:socket],
                cmd_count=1, block_count=0, block_cmd='',
                use_yaml=false, safe_level=3 )
    super()
    self[:socket] = socket
    self[:cmd_count] = cmd_count
    self[:block_count] = block_count
    self[:block_cmd] = block_cmd
    self[:use_yaml] = use_yaml
    self[:safe_level] = safe_level
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, val = nil) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rti/state.rb', line 50

def method_missing( sym, val=nil )
    if key?( sym )
        self[sym]
    else
        str = sym.to_s
        if str[-1] == ?=
            self[str.chop.to_sym] = val
        else
            self[sym]
        end
    end
end