Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/toolbox/json.rb,
lib/toolbox/array.rb

Instance Method Summary collapse

Instance Method Details

#=~(other) ⇒ Object Also known as: contains?

Adds the ability to check if Array contains a subset of objects or a single object. See toolbox/array



6
7
8
9
10
11
12
13
# File 'lib/toolbox/array.rb', line 6

def =~(other)
  if other.is_a?(::Array)
    other.each { |obj| return false unless self.include?(obj) }
    true
  else
    self.include?(other)
  end
end

#to_json_ppObject

Adds in-line ability to pretty-print an Array to JSON using entity.pretty_generate



8
9
10
# File 'lib/toolbox/json.rb', line 8

def to_json_pp
  JSON.pretty_generate(self)
end