Sha256: 2c3b557b48d452d38d78f7346a3093337240face421537893399105fb0723bcf
Contents?: true
Size: 513 Bytes
Versions: 2
Compression:
Stored size: 513 Bytes
Contents
# encoding: utf-8 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
divISOr-1.0.7 | lib/divISOr/iso_records.rb |
divISOr-1.0.4 | lib/divISOr/iso_records.rb |