Sha256: e316bc8349a8ad797420e8581ccfdd05c238650f232d05c83ede03fea5ebaa22
Contents?: true
Size: 495 Bytes
Versions: 4
Compression:
Stored size: 495 Bytes
Contents
class ISORecords attr_reader :data def initialize(path) @data = JSON.parse(File.read(path), :symbolize_names => true) end def values_for(fields) fields = [fields] unless fields.is_a?(Array) data.map{|record| fields.map{|field| record[field.to_sym] }}.flatten.compact.map(&:upcase) end def all(value, fields) fields = [fields] unless fields.is_a?(Array) return data if value.nil? data.select{|record| fields.any?{|field| record[field] == value}} end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
divISOr-1.0.3 | lib/divISOr/iso_records.rb |
divISOr-1.0.2 | lib/divISOr/iso_records.rb |
divISOr-1.0.1 | lib/divISOr/iso_records.rb |
divISOr-1.0.0 | lib/divISOr/iso_records.rb |