Sha256: 044aeda66473b767d888fb090451b3b35813cc4ccb47cc0a06072573d45fc845

Contents?: true

Size: 965 Bytes

Versions: 4

Compression:

Stored size: 965 Bytes

Contents

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

module Bioinform
  # TrivialParser can be used to parse hashes returned by #parse method of other parsers:
  # PM.new({matrix:[[1,2,3,4],[5,6,7,8]], name: 'Name'}, TrivialParser)
  # PM.new(StringParser.new("1 2 3 4\n5 6 7 8").parse)
  # StringParser.new("First\n1 2 3 4\n5 6 7 8\nSecond\n0 0 0 0").map{|inp| PM.new(inp, TrivialParser)}
  class TrivialParser < Parser
    def initialize(input)
      @input = input
    end
    def parse!
      case input
      when PM then input
      when Motif then input.pm
      when OpenStruct then input
      when Hash then OpenStruct.new(input)
      end
    end
  end

  class TrivialCollectionParser < Parser
    include MultipleMotifsParser
    def initialize(input)
      @input = input
    end
    def parse!
      input.container.shift.pm
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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