Sha256: 139187fd3a23fdcdccf7b3a6398fd8d743d252933c96f8dfe4e0231661a1b1d0

Contents?: true

Size: 776 Bytes

Versions: 11

Compression:

Stored size: 776 Bytes

Contents

class GraphViz
  class Elements
    def initialize
      @elements = Array.new
      @elements_hash_by_type = Hash.new
    end

    def push( obj )
      @elements.push( obj )
      if @elements_hash_by_type[obj['type']].nil?
        @elements_hash_by_type[obj['type']] = Array.new
      end

      @elements_hash_by_type[obj['type']].push( obj )
    end

    def each( &b )
      @elements.each do |e|
        yield( e )
      end
    end

    def size_of( type )
      if @elements_hash_by_type[type].nil?
        return 0
      else
        return @elements_hash_by_type[type].size
      end
    end

    def []( index, type = nil )
      if type.nil?
        return @elements[index]
      else
        return @elements_hash_by_type[type][index]
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
ruby-graphviz-1.2.5 lib/graphviz/elements.rb
ruby-graphviz-1.2.4 lib/graphviz/elements.rb
ruby-graphviz-1.2.3 lib/graphviz/elements.rb
ruby-graphviz-1.2.2 lib/graphviz/elements.rb
ruby-graphviz-1.2.1 lib/graphviz/elements.rb
ruby-graphviz-1.2.0 lib/graphviz/elements.rb
ruby-graphviz-1.1.0 lib/graphviz/elements.rb
ruby-graphviz_c-1.1.1 lib/graphviz/elements.rb
ruby-graphviz_c-1.1.0 lib/graphviz/elements.rb
ruby-graphviz-1.0.9 lib/graphviz/elements.rb
ruby-graphviz-1.0.8 lib/graphviz/elements.rb