Method: PSD.open

Defined in:
lib/psd.rb

.open(filename, opts = {}, &block) ⇒ PSD

Opens the named file, parses it, and makes it available for reading. Then, closes it after you’re finished.

Parameters:

  • filename (String)

    the name of the file to open

Returns:

  • (PSD)

    the PSD object if no block was given, otherwise the value of the block



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/psd.rb', line 37

def self.open(filename, opts={}, &block)
  psd = PSD.new(filename, opts)
  psd.parse!

  return psd unless block_given?

  if 0 == block.arity
    psd.instance_eval(&block)
  else
    yield psd
  end
ensure
  psd.close if psd
end