Sha256: c9defeeaaf115a6bbd384e4544f14bb879fc91339f50e1a3aa3ff2fed07bf956

Contents?: true

Size: 700 Bytes

Versions: 1

Compression:

Stored size: 700 Bytes

Contents

require "yaml"

module YAML
  module SymbolMatrix
    # Calls #merge! using the parsed YAML data as argument
    def from_yaml yaml
      merge! YAML.load yaml
    end
    
    # Calls #merge! using the parsed YAML data from the file
    def from_file path
      merge! YAML.load_file path
    end
    
    # Can I override initialize and call super anyways??
    def initialize argument = nil
    end
  end
end

class SymbolMatrix
  include YAML::SymbolMatrix
  
  def initialize argument = nil
    if argument.is_a? String
      if File.exist? argument
        from_file argument
      else
        from_yaml argument
      end
    else
      merge! argument unless argument.nil?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
symbolmatrix-0.0.1 lib/yaml/symbolmatrix.rb