Sha256: 49658bf87aca81ee2375ec4132c8b8fcfa25acc05a3eeefe2e361eda0915418d
Contents?: true
Size: 663 Bytes
Versions: 1
Compression:
Stored size: 663 Bytes
Contents
require 'forwardable' module Parliament class Response include Enumerable extend Forwardable attr_reader :nodes def_delegators :@nodes, :size, :each, :select, :map, :select!, :map!, :count, :length, :[] def initialize(nodes) @nodes = nodes end def filter(*types) filtered_objects = Array.new(types.size) { [] } unless types.empty? @nodes.each do |node| type_index = types.index(node.type) filtered_objects[type_index] << node unless type_index.nil? end end filtered_objects.each do |objects| Parliament::Response.new(objects) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
parliament-ruby-0.2.0 | lib/parliament/response.rb |