Class: Array
Defined Under Namespace
Classes: Seq
Instance Method Summary collapse
- #apricot_call(idx) ⇒ Object
-
#apricot_inspect ⇒ Object
(also: #apricot_str)
Adapted from Array#inspect.
- #to_seq ⇒ Object
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_inspect ⇒ Object 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 |