Sha256: 92e16e24979f258cefaec75a1bff6f5fa00254e120e844d63013c84c1137666b

Contents?: true

Size: 594 Bytes

Versions: 6

Compression:

Stored size: 594 Bytes

Contents

module D3
  class Set
    include D3::Native
    alias_native :empty?, :empty
    alias_native :has?, :has
    aliases_native %i[size values]
    aliases_native_chainable %i[add clear remove]

    def each(&block)
      @native.JS.each(block)
      self
    end

    def inspect
      "#<D3::Set: {#{ values.join(", ") }}>"
    end
  end

  class << self
    def set(array=nil, &block)
      if block_given?
        D3::Set.new @d3.JS.set(array, proc{|x| yield(x)})
      elsif array
        D3::Set.new @d3.JS.set(array)
      else
        D3::Set.new @d3.JS.set()
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyper-d3-1.0.0.lap28 lib/d3/set.rb
hyper-d3-1.0.0.lap27 lib/d3/set.rb
hyper-d3-1.0.0.lap26 lib/d3/set.rb
hyper-d3-1.0.0.lap25 lib/d3/set.rb
hyper-d3-1.0.0.lap24 lib/d3/set.rb
hyper-d3-1.0.0.lap23 lib/d3/set.rb