Class: XProc::Proc
- Inherits:
- BasicObject
- Defined in:
- lib/xproc.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
-
#initialize(index, invocations = []) ⇒ Proc
constructor
A new instance of Proc.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing? ⇒ Boolean
- #to_proc ⇒ Object
Constructor Details
#initialize(index, invocations = []) ⇒ Proc
Returns a new instance of Proc.
7 8 9 10 |
# File 'lib/xproc.rb', line 7 def initialize(index, invocations = []) @index = index @invocations = invocations end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
5 6 7 |
# File 'lib/xproc.rb', line 5 def index @index end |
Instance Method Details
#respond_to_missing? ⇒ Boolean
29 30 31 |
# File 'lib/xproc.rb', line 29 def respond_to_missing?(*) true end |
#to_proc ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/xproc.rb', line 12 def to_proc invocations = @invocations index = @index ::Kernel.lambda do |*proc_args| invocations.reduce(proc_args[index]) do |val, (name, args, block)| args = args.map do |arg| if arg.is_a?(::XProc::Proc) proc_args[arg.index] else arg end end val.send(name, *args, &block) end end end |