Class: RBridge::RResultManager
- Inherits:
-
Object
- Object
- RBridge::RResultManager
- Defined in:
- lib/r_bridge/r_bridge_lazyfunc_ext.rb
Instance Method Summary collapse
- #add_inst(inst_name) ⇒ Object
- #add_inst_r_obj(inst_name, r_obj) ⇒ Object
-
#get_last_for(r_result) ⇒ Object
If corresponding result name is not found, return r_nil().
-
#get_last_index_for(result_name) ⇒ Object
From this method, if result name is not found return (Ruby) nil.
- #get_previous ⇒ Object
- #get_previous_inst_name ⇒ Object
-
#initialize ⇒ RResultManager
constructor
A new instance of RResultManager.
Constructor Details
#initialize ⇒ RResultManager
Returns a new instance of RResultManager.
176 177 178 |
# File 'lib/r_bridge/r_bridge_lazyfunc_ext.rb', line 176 def initialize @results = [] end |
Instance Method Details
#add_inst(inst_name) ⇒ Object
180 181 182 |
# File 'lib/r_bridge/r_bridge_lazyfunc_ext.rb', line 180 def add_inst( inst_name ) @results << [inst_name, RBridge::r_lang_nil() ] end |
#add_inst_r_obj(inst_name, r_obj) ⇒ Object
184 185 186 |
# File 'lib/r_bridge/r_bridge_lazyfunc_ext.rb', line 184 def add_inst_r_obj( inst_name, r_obj ) @results << [inst_name, r_obj ] end |
#get_last_for(r_result) ⇒ Object
If corresponding result name is not found, return r_nil().
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/r_bridge/r_bridge_lazyfunc_ext.rb', line 206 def get_last_for( r_result ) # If corresponding result name is not found, return r_nil(). raise "get_last_for method requires RResultName or RResultNameArray for its argument." if ! ( r_result.is_a?(RResultName) || r_result.is_a?(RResultNameArray) ) if( r_result.is_a? RResultName) inst_name = r_result.name elem_to_match = @results.reverse.find{|elem| elem[0] == inst_name } if elem_to_match.nil? return RBridge::r_nil() else r_obj = elem_to_match[1] if RBridge::is_r_nil?( r_obj ) return RBridge::r_nil() else return r_obj end end elsif( r_result.is_a? RResultNameArray) index_array = r_result.elems.map(){|result_name| if result_name.is_a? RResultName get_last_index_for( result_name ) else p result_name raise "RResultNameArray should hold only RResultName objects" end } if( index_array.all?(nil) ) return RBridge::r_nil() else index_array.delete(nil) if ! index_array.empty? last_idx = index_array.max r_obj = @results[last_idx][1] return r_obj else return RBridge::r_nil() end end else raise "get_last_for() takes unexpected object" end end |
#get_last_index_for(result_name) ⇒ Object
From this method, if result name is not found return (Ruby) nil.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/r_bridge/r_bridge_lazyfunc_ext.rb', line 188 def get_last_index_for( result_name ) # From this method, if result name is not found return (Ruby) nil. name = result_name.name idx = @results.size - 1 @results.reverse.each{|inst_name, r_obj| if inst_name == name break else idx = idx - 1 end } if idx < 0 return nil else return idx end end |
#get_previous ⇒ Object
249 250 251 252 253 254 255 256 |
# File 'lib/r_bridge/r_bridge_lazyfunc_ext.rb', line 249 def get_previous() if @results.size > 0 r_obj = @results.last[1] return r_obj else return RBridge::r_nil() end end |
#get_previous_inst_name ⇒ Object
258 259 260 261 262 263 264 265 266 |
# File 'lib/r_bridge/r_bridge_lazyfunc_ext.rb', line 258 def get_previous_inst_name() if @results.size > 0 last_inst_name = @results.last[0] r_obj = RBridge::create_strvec([last_inst_name]) return r_obj else return RBridge::r_nil() end end |