Sha256: 7f23b129f8b216bbcafcc8af4ffcb9fd26352bceb6ce843543fccc3d67671729

Contents?: true

Size: 379 Bytes

Versions: 4

Compression:

Stored size: 379 Bytes

Contents

class Array
  # Ensures that the array contains only one element
  def ensure_single(a_noun, a_context)
    if self.size != 1
      $stderr.puts "ERROR: expected 1 #{a_noun}, found #{self.size} (#{a_context})" unless $quiet
      exit
    end
  end

  # Pushes the object on the stack, yields, and pops stack
  def pushing(obj)
    push(obj)
    yield
  ensure
    pop
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nanoc-1.5 lib/nanoc/core_ext/array.rb
nanoc-1.6.1 lib/nanoc/core_ext/array.rb
nanoc-1.6 lib/nanoc/core_ext/array.rb
nanoc-1.6.2 lib/nanoc/core_ext/array.rb