Class: Tcl::Ruby::ListArray

Inherits:
Object
  • Object
show all
Defined in:
lib/tcl/ruby/list_array.rb

Instance Method Summary collapse

Constructor Details

#initializeListArray

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_listObject



26
27
28
# File 'lib/tcl/ruby/list_array.rb', line 26

def to_list
  @ary.map { |e| _to_list(e) }.join(' ')
end

#to_stringObject



21
22
23
24
# File 'lib/tcl/ruby/list_array.rb', line 21

def to_string
  @ary.map! { |e| _to_string(e) }
  self
end