Class: Array

Inherits:
Object show all
Includes:
NOMS::BashOn
Defined in:
lib/noms/bashon.rb,
lib/noms/bashon.rb

Overview

Enumerable?

Instance Method Summary collapse

Methods included from NOMS::BashOn

#name_key

Instance Method Details

#nitemsObject



330
331
332
# File 'lib/noms/bashon.rb', line 330

def nitems
   count { |x| !x.nil? }
end

#to_bashon(*name) ⇒ Object



339
340
341
342
343
344
345
346
# File 'lib/noms/bashon.rb', line 339

def to_bashon(*name)
   "function #{name_key(name)} { echo " +
      (0 .. (self.nitems-1)).map { |i|
      name_key(name + [i.to_s]) }.join(' ') + "; } " +
      (self.empty? ? ' ' : '; ') +
      (0 .. (self.nitems-1)).map { |i|
      self[i].to_bashon(*(name + [i.to_s])) }.join(';')
end