Class: RLTK::CG::User::OperandCollection
- Inherits:
-
Object
- Object
- RLTK::CG::User::OperandCollection
- Includes:
- Enumerable
- Defined in:
- lib/rltk/cg/value.rb
Overview
This class is used to access a User’s operands.
Instance Method Summary collapse
-
#[](index) ⇒ Value?
Access the operand at the given index.
-
#[]=(index, value) ⇒ void
Set the operand at the given index.
-
#each {|val| ... } ⇒ Enumerator
An iterator for each operand inside this collection.
-
#initialize(user) ⇒ OperandCollection
constructor
A new instance of OperandCollection.
-
#size ⇒ Integer
Number of operands.
Constructor Details
#initialize(user) ⇒ OperandCollection
Returns a new instance of OperandCollection.
229 230 231 |
# File 'lib/rltk/cg/value.rb', line 229 def initialize(user) @user = user end |
Instance Method Details
#[](index) ⇒ Value?
Access the operand at the given index.
238 239 240 |
# 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) ⇒ void
This method returns an undefined value.
Set the operand at the given index.
248 249 250 |
# File 'lib/rltk/cg/value.rb', line 248 def []=(index, value) Bindings.set_operand(@user, index, check_type(value, Value, 'value')) end |
#each {|val| ... } ⇒ Enumerator
An iterator for each operand inside this collection.
257 258 259 260 261 262 263 |
# 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 ⇒ Integer
Returns Number of operands.
266 267 268 |
# File 'lib/rltk/cg/value.rb', line 266 def size Bindings.get_num_operands(@user) end |