Class: Pa::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/pa/util.rb

Defined Under Namespace

Modules: Concern

Class Method Summary collapse

Class Method Details

.extract_options(ary, default = {}) ⇒ Array<Array,Hash>

extract options

Examples:

def mkdir(*args)
  paths, o = args.extract_options
end

Returns:

  • (Array<Array,Hash>)

See Also:

  • extract_options!


19
20
21
22
23
24
25
# File 'lib/pa/util.rb', line 19

def extract_options(ary, default={})
  if ary.last.is_a?(Hash) && ary.last.instance_of?(Hash)
    [ary[0...-1], ary[-1].merge(default)]
  else
    [ary, default]
  end
end

.join(dir, *names) ⇒ Object

join(“.”, “foo”) => “foo” not “./foo”



36
37
38
# File 'lib/pa/util.rb', line 36

def join(dir, *names)
  dir == "." ? File.join(*names) : File.join(dir, *names)
end

.win32?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/pa/util.rb', line 31

def win32? 
  RUBY_PLATFORM =~ /mingw32|mswin/ 
end

.wrap_array(value) ⇒ Object



27
28
29
# File 'lib/pa/util.rb', line 27

def wrap_array(value)
  Array === value ? value : [value]
end