Class: RIO::Cx::Vars
Constant Summary
collapse
- BEQUEATH_KEYS =
%w[chomp strip rename closeoneof closeoncopy]
Instance Method Summary
collapse
Methods included from Fwd
fwd, fwd_reader, fwd_readers, fwd_writer, fwd_writers
Constructor Details
#initialize(h = Hash.new, exp = Hash.new) ⇒ Vars
Returns a new instance of Vars.
34
35
36
37
|
# File 'lib/rio/context.rb', line 34
def initialize(h=Hash.new,exp=Hash.new)
@values = h
@explicit = exp
end
|
Instance Method Details
#[]=(key, val) ⇒ Object
75
76
77
78
|
# File 'lib/rio/context.rb', line 75
def []=(key,val)
@values[key] = val
@explicit[key] = true
end
|
#bequeath(oldcx) ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/rio/context.rb', line 44
def bequeath(oldcx)
keys = BEQUEATH_KEYS
ncx = oldcx.clone
keys.each { |key|
ncx.set_(key,@values[key]) if @values.has_key?(key)
}
ncx
end
|
#delete(key) ⇒ Object
53
54
55
56
|
# File 'lib/rio/context.rb', line 53
def delete(key)
@values.delete(key)
@explicit.delete(key)
end
|
#get_keystate(key) ⇒ Object
57
58
59
60
61
62
|
# File 'lib/rio/context.rb', line 57
def get_keystate(key)
key_exists = @values.key?(key)
key_val = @values[key]
key_explicit = @explicit[key]
[key,key_exists,key_val,key_explicit]
end
|
#initialize_copy(*args) ⇒ Object
38
39
40
41
42
|
# File 'lib/rio/context.rb', line 38
def initialize_copy(*args)
super
@values = @values.clone
@explicit = @explicit.clone
end
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/rio/context.rb', line 88
def inspect()
str = sprintf('#<Cx:0x%08x ',self.object_id)
vary = {}
@values.each { |k,v|
name = k
name += '_' unless @explicit[k]
if v == true
vary[name] = nil
elsif v == false
vary[name] = 'false'
else
vary[name] = v
end
}
strs = []
vary.each { |k,v|
if v.nil?
strs << k
else
strs << "#{k}(#{v.inspect})"
end
}
str += strs.join(',')
str +='>'
str
end
|
#set_(key, val) ⇒ Object
72
73
74
|
# File 'lib/rio/context.rb', line 72
def set_(key,val)
@values[key] = val unless @explicit[key]
end
|
#set_keystate(key, key_exists, key_val, key_explicit) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/rio/context.rb', line 63
def set_keystate(key,key_exists,key_val,key_explicit)
if(key_exists) then
@values[key] = key_val
@explicit[key] = key_explicit
else
@values.delete(key)
@explicit.delete(key)
end
end
|
79
80
81
82
83
84
85
86
87
|
# File 'lib/rio/context.rb', line 79
def to_h
vary = {}
@values.each { |k,v|
name = k
name += '_' unless @explicit[k]
vary[name] = v
}
vary
end
|