Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/xmlresume2x/wrapper.rb

Overview

$Id: wrapper.rb 27 2005-01-12 20:17:13Z thomas $

xmlresume2x: converts an xml resume to various output formats Copyright © 2004 Thomas Leitner

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

++

Direct Known Subclasses

XMLResume2x::ElementWrapperList

Instance Method Summary collapse

Instance Method Details

#join(sep = $,) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/xmlresume2x/wrapper.rb', line 26

def join( sep = $, )
  if sep.instance_of?( String ) || sep.instance_of?( NilClass )
    self.collect {|i| i.to_s}.old_join( sep )
  else
    arr = []
    self.each_with_index {|e, i| arr << sep.clone if i > 0; arr << e}
    arr
  end
end

#old_joinObject



25
# File 'lib/xmlresume2x/wrapper.rb', line 25

alias_method :old_join, :join

#separate_by(sep, sepLast) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/xmlresume2x/wrapper.rb', line 36

def separate_by( sep, sepLast )
  result = self[0..-2].join( sep )
  case self.length
  when 0 then result
  when 1 then self.last
  when 2
    if result.kind_of? String
      result << sepLast.to_s << self.last.to_s
    else
      result << sepLast << self.last
    end
  end
end