Sha256: e7d72dc66c3056f7f7194fc116be1e71621b1a149791e6373cdcbd1fe917c777

Contents?: true

Size: 815 Bytes

Versions: 5

Compression:

Stored size: 815 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

5 entries across 5 versions & 1 rubygems

Version Path
bioinform-0.1.17 lib/bioinform/parsers/yaml_parser.rb
bioinform-0.1.16 lib/bioinform/parsers/yaml_parser.rb
bioinform-0.1.15 lib/bioinform/parsers/yaml_parser.rb
bioinform-0.1.14 lib/bioinform/parsers/yaml_parser.rb
bioinform-0.1.13 lib/bioinform/parsers/yaml_parser.rb