Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/openhab/core_ext/ruby/array.rb

Overview

Extensions to Array

Class Method Summary collapse

Class Method Details

.wrap(object) ⇒ Array

Ensure an object is an array, by wrapping it in an array if it’s not already an array.



12
13
14
15
16
17
18
19
20
# File 'lib/openhab/core_ext/ruby/array.rb', line 12

def self.wrap(object)
  if object.nil?
    []
  elsif object.respond_to?(:to_ary)
    object.to_ary
  else
    [object]
  end
end