Sha256: 5184563571ff082638489a255ed057bc7d2cc6c06debd242687f1de161ff0f29

Contents?: true

Size: 638 Bytes

Versions: 4

Compression:

Stored size: 638 Bytes

Contents

require 'rubrowser/parser/factory'

module Rubrowser
  class Data
    def initialize(files)
      @files = files
      @parsed = false
      parse
    end

    def definitions
      @_constants ||= parsers.map(&:definitions).reduce(:+).to_a
    end

    def relations
      @_relations ||= parsers.map(&:relations).reduce(:+).to_a
    end

    private

    def parse
      return if parsed?
      parsers.each(&:parse)
      @parsed = true
    end

    attr_reader :files, :parsed
    alias parsed? parsed

    def parsers
      @_parsers ||= files.map do |file|
        Rubrowser::Parser::Factory.build(file)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubrowser-0.2.6 lib/rubrowser/data.rb
rubrowser-0.2.5 lib/rubrowser/data.rb
rubrowser-0.2.4 lib/rubrowser/data.rb
rubrowser-0.2.3 lib/rubrowser/data.rb