Class: Array

Inherits:
Object show all
Defined in:
lib/apricot/ruby_ext.rb

Defined Under Namespace

Classes: Seq

Instance Method Summary collapse

Instance Method Details

#apricot_call(idx) ⇒ Object



37
38
39
# File 'lib/apricot/ruby_ext.rb', line 37

def apricot_call(idx)
  self[idx]
end

#apricot_inspectObject Also known as: apricot_str

Adapted from Array#inspect. This version prints no commas and calls #apricot_inspect on its elements. e.g. [1 2 3]



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/apricot/ruby_ext.rb', line 24

def apricot_inspect
  return '[]' if size == 0

  str = '['

  return '[...]' if Thread.detect_recursion self do
    each {|x| str << x.apricot_inspect << ' ' }
  end

  str.chop!
  str << ']'
end

#to_seqObject



43
44
45
46
47
48
49
# File 'lib/apricot/ruby_ext.rb', line 43

def to_seq
  if length == 0
    nil
  else
    Seq.new(self, 0)
  end
end