class RLTK::CG::User::OperandCollection

This class is used to access a {User User’s} operands.

Public Class Methods

new(user) click to toggle source

@param [User] user User object for which this is a proxy.

# File lib/rltk/cg/value.rb, line 229
def initialize(user)
        @user = user
end

Public Instance Methods

[](index) click to toggle source

Access the operand at the given index.

@param [Integer] index

@return [Value, nil] Value object representing the operand at index if one exists.

# File lib/rltk/cg/value.rb, line 238
def [](index)
        if (ptr = Bindings.get_operand(@user, index)).null? then nil else Value.new(ptr) end
end
[]=(index, value) click to toggle source

Set the operand at the given index.

@param [Integer] index Index of operand to set. @param [Value] value Value to set as operand.

@return [void]

# File lib/rltk/cg/value.rb, line 248
def []=(index, value)
        Bindings.set_operand(@user, index, check_type(value, Value, 'value'))
end
each() { |self| ... } click to toggle source

An iterator for each operand inside this collection.

@yieldparam val [Value]

@return [Enumerator] Returns an Enumerator if no block is given.

# File lib/rltk/cg/value.rb, line 257
def each
        return to_enum(:each) unless block_given?

        self.size.times { |i| yield self[i] }

        self
end
size() click to toggle source

@return [Integer] Number of operands.

# File lib/rltk/cg/value.rb, line 266
def size
        Bindings.get_num_operands(@user)
end