class RCGTK::Function::ParameterCollection
This class is used to access a function’s parameters.
Public Class Methods
new(fun)
click to toggle source
@param [Function] fun Function
for which this is a proxy.
# File lib/rcgtk/function.rb, line 196 def initialize(fun) @fun = fun end
Public Instance Methods
[](index)
click to toggle source
Access the parameter at the given index.
@param [Integer] index Index of the desired parameter. May be negative.
@return [Value] Value
object representing the parameter.
# File lib/rcgtk/function.rb, line 205 def [](index) index += self.size if index < 0 if 0 <= index and index < self.size Value.new(Bindings.get_param(@fun, index)) end end
each() { |self| ... }
click to toggle source
An iterator for each parameter inside this collection.
@yieldparam val [Value]
@return [Enumerator] Returns an Enumerator if no block is given.
# File lib/rcgtk/function.rb, line 218 def each return to_enum :each unless block_given? self.size.times { |index| yield self[index] } self end
size()
click to toggle source
@return [Integer] Number of function parameters.
# File lib/rcgtk/function.rb, line 227 def size Bindings.count_params(@fun) end
to_a()
click to toggle source
@return [Array<Value>] Array of Value
objects representing the function parameters.
# File lib/rcgtk/function.rb, line 232 def to_a self.size.times.to_a.inject([]) { |params, index| params << self[index] } end