Sha256: 9990f149ef8b0b7d0adee1bda1646bdb8c2f62c0986b92130775cc7f0972e6af

Contents?: true

Size: 746 Bytes

Versions: 4

Compression:

Stored size: 746 Bytes

Contents

require 'parser/factory'
require 'tree'
require 'd3'

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

    def constants
      @_constants ||= d3.constants.to_a
    end

    def occurences
      @_occurences ||= d3.occurences.to_a
    end

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

    private

    attr_reader :files, :parsed
    alias parsed? parsed

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

    def d3
      @_d3 ||= Rubrowser::D3.new(tree)
    end

    def tree
      parse
      @_tree ||= Rubrowser::Tree.from_parsers(parsers)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubrowser-0.1.6 lib/data.rb
rubrowser-0.1.5 lib/data.rb
rubrowser-0.1.4 lib/data.rb
rubrowser-0.1.3 lib/data.rb