Sha256: 8ff74779e35862140b75ea46cef1e4086d05406154b919a99b6b310d3f004059

Contents?: true

Size: 849 Bytes

Versions: 4

Compression:

Stored size: 849 Bytes

Contents

require_relative '../support'
require_relative 'parser'
require_relative '../data_models/collection'
require 'yaml'

module Bioinform
  # YAMLParser can be used to parse hashes returned by #parse method of other parsers:
  # yaml_dump_of_pm = PM.new(...).to_yaml
  # PM.new(yaml_dump_of_pm, YAMLParser)
  class YAMLParser < Parser
    def initialize(input)
      @input = input
    end
    def parse!
      YAML.load(input)
    rescue Psych::SyntaxError
      raise 'parsing error'
    end
  end

  class YAMLCollectionParser < Parser
    include MultipleMotifsParser
    def initialize(input)
      @input = input
    end
    def collection
      @collection ||= YAML.load(input)
    end
    def parse!
      collection.container.shift.pm
    rescue Psych::SyntaxError
      raise 'parsing error'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bioinform-0.1.12 lib/bioinform/parsers/yaml_parser.rb
bioinform-0.1.11 lib/bioinform/parsers/yaml_parser.rb
bioinform-0.1.10 lib/bioinform/parsers/yaml_parser.rb
bioinform-0.1.9 lib/bioinform/parsers/yaml_parser.rb