Class: Tcl::Ruby::ListArray
- Inherits:
-
Object
- Object
- Tcl::Ruby::ListArray
- Defined in:
- lib/tcl/ruby/list_array.rb
Instance Method Summary collapse
- #<<(buffer) ⇒ Object
- #[](arg) ⇒ Object
-
#initialize ⇒ ListArray
constructor
A new instance of ListArray.
- #map(&block) ⇒ Object
- #map!(&block) ⇒ Object
- #to_list ⇒ Object
- #to_string ⇒ Object
Constructor Details
#initialize ⇒ ListArray
Returns a new instance of ListArray.
11 12 13 |
# File 'lib/tcl/ruby/list_array.rb', line 11 def initialize @ary = [] end |
Instance Method Details
#<<(buffer) ⇒ Object
15 16 17 18 19 |
# File 'lib/tcl/ruby/list_array.rb', line 15 def <<(buffer) @ary << buffer.dup unless buffer.empty? buffer.clear self end |
#[](arg) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/tcl/ruby/list_array.rb', line 41 def [](arg) if arg.is_a?(Range) r = dup r.ary = r.ary[arg] r else @ary.[](arg) end end |
#map(&block) ⇒ Object
35 36 37 38 39 |
# File 'lib/tcl/ruby/list_array.rb', line 35 def map(&block) r = dup r.map!(&block) r end |
#map!(&block) ⇒ Object
30 31 32 33 |
# File 'lib/tcl/ruby/list_array.rb', line 30 def map!(&block) @ary.map!(&block) self end |
#to_list ⇒ Object
26 27 28 |
# File 'lib/tcl/ruby/list_array.rb', line 26 def to_list @ary.map { |e| _to_list(e) }.join(' ') end |
#to_string ⇒ Object
21 22 23 24 |
# File 'lib/tcl/ruby/list_array.rb', line 21 def to_string @ary.map! { |e| _to_string(e) } self end |