Sha256: b90faf6679cbfda3334c47b028def65a1f6b75cd77cf41d97c9dd139c1577bde

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

# -*- coding: utf-8 -*-

module Bio
  module FastQC
    class Converter
      def initialize(summary_json, id: nil)
        @id = id
        @summary_json = summary_json
      end

      def convert_to(format)
        case format
        when "json"
          to_json
        when "json-ld"
          to_jsonld
        when "turtle"
          to_turtle
        end
      end

      def to_json
        json = if @id
                 { @id => @summary_json }
               else
                 @summary_json
               end
        JSON.dump(json)
      end

      def to_jsonld
        json_ld_object = Semantics.new(@summary_json, id: @id).json_ld_object
        JSON.dump(json_ld_object)
      end

      def to_turtle
        Semantics.new(@summary_json, id: @id).turtle
      end

      def to_ttl
        to_turtle
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bio-fastqc-0.4.2 lib/bio/fastqc/converter.rb
bio-fastqc-0.4.1 lib/bio/fastqc/converter.rb
bio-fastqc-0.4.0 lib/bio/fastqc/converter.rb