Class: RubimCode::UserArray

Inherits:
Array
  • Object
show all
Defined in:
lib/rubimc.rb

Overview

end LoopCounter class

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



153
154
155
# File 'lib/rubimc.rb', line 153

def name
  @name
end

#typeObject

Returns the value of attribute type.



153
154
155
# File 'lib/rubimc.rb', line 153

def type
  @type
end

Instance Method Details

#[](index) ⇒ Object



159
160
161
# File 'lib/rubimc.rb', line 159

def [](index)
  super index.to_i
end

#[]=(index, val) ⇒ Object



155
156
157
# File 'lib/rubimc.rb', line 155

def []=(index, val)
  RubimCode.pout "#{@name}[#{index.to_i}] = #{val.to_s};"
end

#each {|self[0].class.new("#{joy_name}")| ... } ⇒ Object

Yields:

  • (self[0].class.new("#{joy_name}"))


163
164
165
166
167
168
169
170
171
# File 'lib/rubimc.rb', line 163

def each
  n = LoopCounter.new
  RubimCode.pout "for (int #{n}=0; #{n}<#{self.size}; #{n}++) {"
  RubimCode.level +=1
  joy_name = self.name + "[#{n}]"
  yield(self[0].class.new("#{joy_name}"))
  RubimCode.level -=1
  RubimCode.pout "}"
end