class Tuple
Attributes
elements[R]
first[R]
last[R]
size[R]
Public Class Methods
new(*elements)
click to toggle source
# File lib/static_ruby.rb, line 70 def initialize(*elements) @elements = elements @size = elements.size @first = elements.size != 0 ? elements[0] : nil @last = elements.size != 0 ? elements[-1] : nil end
Public Instance Methods
!=(o)
click to toggle source
# File lib/static_ruby.rb, line 89 def !=(o) @elements != o.elements end
==(o)
click to toggle source
# File lib/static_ruby.rb, line 85 def ==(o) @elements == o.elements end
[](i)
click to toggle source
# File lib/static_ruby.rb, line 93 def [](i) @elements[i] end
[]=(_, _)
click to toggle source
# File lib/static_ruby.rb, line 97 def []=(_, _) raise('Tuple cannot be modified') end
each(&block)
click to toggle source
# File lib/static_ruby.rb, line 101 def each(&block) @elements.each do |x| block.call(x) end end
each_with_index(&block)
click to toggle source
# File lib/static_ruby.rb, line 107 def each_with_index(&block) @elements.each_with_index do |x, i| block.call(x, i) end end
to_a()
click to toggle source
# File lib/static_ruby.rb, line 77 def to_a @elements end
to_s()
click to toggle source
# File lib/static_ruby.rb, line 81 def to_s "Tuple(#{@elements.map { |x| x.to_s }})" end