Module: Kernel

Defined in:
lib/rook/helper/kernel.rb

Overview

add several global functions.

these are convenience for non-ruby user and compatibility with Kook.

Class Method Summary collapse

Class Method Details

.array_basenames(array) ⇒ Object



84
85
86
# File 'lib/rook/helper/kernel.rb', line 84

def array_basenames(array)
  return array.collect { |item| File.basename(item) }
end

.array_delete_prefix(array, prefix) ⇒ Object



67
68
69
# File 'lib/rook/helper/kernel.rb', line 67

def array_delete_prefix(array, prefix)
  return array.collect { |item| item.sub(prefix, '') }
end

.array_delete_suffix(array, suffix = /\.\w+\z/) ⇒ Object



55
56
57
# File 'lib/rook/helper/kernel.rb', line 55

def array_delete_suffix(array, suffix=/\.\w+\z/)
  return array.collect { |item| item.sub(suffix, '') }
end

.array_dirnames(array) ⇒ Object



96
97
98
# File 'lib/rook/helper/kernel.rb', line 96

def array_dirnames(array)
  return array.collect { |item| File.dirname(item) }
end

.array_join(array, separator) ⇒ Object



79
80
81
# File 'lib/rook/helper/kernel.rb', line 79

def array_join(array, separator)
  return array.join(separator)
end

.array_prefix(array, prefix) ⇒ Object



19
20
21
# File 'lib/rook/helper/kernel.rb', line 19

def array_prefix(array, prefix)
  return array.collect { |item| "#{prefix}#{item}" }
end

.array_sandwich(array, prefix, suffix) ⇒ Object



43
44
45
# File 'lib/rook/helper/kernel.rb', line 43

def array_sandwich(array, prefix, suffix)
  return array.collect { |item| "#{prefix}#{item}#{suffix}" }
end

.array_suffix(array, suffix) ⇒ Object



31
32
33
# File 'lib/rook/helper/kernel.rb', line 31

def array_suffix(array, suffix)
  return array.collect { |item| "#{item}#{suffix}" }
end