Class: RVM::Classes::List

Inherits:
Array
  • Object
show all
Extended by:
Plugin
Defined in:
lib/rvm/classes/list.rb

Constant Summary collapse

@@type =
:list

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Plugin

helper, included, plugin_host, plugin_id, register_for

Constructor Details

#initialize(source = [], sepperator = ' ') ⇒ List

Returns a new instance of List.



27
28
29
30
31
32
33
34
35
36
# File 'lib/rvm/classes/list.rb', line 27

def initialize source= [], sepperator = ' '
  super()
  if source.is_a?(::String) # Okay we've to hack here to get sure we get the /real/ String
    source = source.split sepperator
  elsif !source.is_a?(Array)
    source = [source]
  end
  self.concat source
  @sepperator = sepperator.to_s
end

Instance Attribute Details

#sepperatorObject

Returns the value of attribute sepperator.



8
9
10
# File 'lib/rvm/classes/list.rb', line 8

def sepperator
  @sepperator
end

Instance Method Details

#data_typeObject



10
11
12
# File 'lib/rvm/classes/list.rb', line 10

def data_type
  :list
end

#functionsObject



20
21
22
23
24
25
# File 'lib/rvm/classes/list.rb', line 20

def functions
  @functions ||= {
    'size' => RVM::Functions[:size],
    'length' => RVM::Functions[:size]
  }
end

#resplit(sep) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/rvm/classes/list.rb', line 38

def resplit(sep)
  sep = sep.to_s
  if sep != @sepperator
    t = self.join(@sepperator)
    @sepperator = sep
    self.clear
    self.concat(t.split(sep))
  end
end

#to_sObject



52
53
54
55
56
# File 'lib/rvm/classes/list.rb', line 52

def to_s
  if @sepperator
    map{|i| i.to_s}.join(@sepperator)
  end
end

#variablesObject



15
16
17
# File 'lib/rvm/classes/list.rb', line 15

def variables
  @variables ||= {}
end