Sha256: c0ddd529c0c64d6c76598c8945bb34644eaf3f22733055fa196b9e281811960d

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

module Eyemask
  module Core

    class Loader

      def initialize(options={})
        @options = options
        @contents = []
      end

      def load(uri, data)
        @contents.concat(to_elements(uri, data))
      end

      def done
        # DO NOTHING, HERE AS A HOOK
      end

      def document
        doc = {}
        doc["contents"] = contents
        doc["title"] = @options[:title]
        doc["subtitle"] = @options[:subtitle]
        doc["authors"] = @options[:authors]
        doc["logo"] = @options[:logo]
        doc["params"] = @options[:params]
        doc
      end

      def contents
        @contents.sort{|a, b| a["uri"] <=> b["uri"] }
      end

      private

      def to_elements(uri, data)
        begin
          JSON.parse(data)
        rescue JSON::ParserError
          []
        end
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eyemask-0.1.0 lib/eyemask/core/loader.rb