class Lab42::Console::Wrapper
Attributes
function[R]
subject[R]
Public Class Methods
new(subject, *args, &blk)
click to toggle source
# File lib/lab42/console/wrapper.rb, line 30 def initialize(subject, *args, &blk) _init_function(args, blk) @subject = subject end
Public Instance Methods
add(*args, &blk)
click to toggle source
# File lib/lab42/console/wrapper.rb, line 8 def add(*args, &blk) @function = function.add(*args, &blk) self end
fnd(*args, &blk)
click to toggle source
# File lib/lab42/console/wrapper.rb, line 14 def fnd(*args, &blk) _apply_function .find{ |x| x.apply_to_cdr(_make_function(*args, &blk))&.cdr } &.car end
sel(*args, &blk)
click to toggle source
# File lib/lab42/console/wrapper.rb, line 20 def sel(*args, &blk) filter_function = _make_function(*args, &blk) _apply_function .filter{ |x| x.apply_to_cdr(filter_function)&.cdr } .map(&:car) end
Private Instance Methods
_apply_function()
click to toggle source
# File lib/lab42/console/wrapper.rb, line 35 def _apply_function subject .duplicate .map{ |x| x.apply_to_cdr(function) } end
_init_function(args, blk)
click to toggle source
# File lib/lab42/console/wrapper.rb, line 41 def _init_function(args, blk) @function = Function.new(*args, &blk) end
_make_function(*args, &blk)
click to toggle source
# File lib/lab42/console/wrapper.rb, line 45 def _make_function(*args, &blk) case args.first when Symbol Function.new(*args, &blk) when NilClass Function.new([], &blk) else Function.new(*([:==]+args), &blk) end end