class Census::DataSet

A simple container object that proxies its query method to an underlying DataSetVintage object.

Public Class Methods

new() click to toggle source
# File lib/rboc/data.rb, line 102
def initialize
  @vintages = {}
  @newest_vintage = 0
end

Public Instance Methods

[](vintage) click to toggle source
# File lib/rboc/data.rb, line 117
def [](vintage)
  unless @vintages.keys.include? vintage
    raise ArgumentError, "Unknown vintage"
  end
  @vintages[vintage.to_i]
end
add_vintage(v) click to toggle source
# File lib/rboc/data.rb, line 107
def add_vintage(v)
  y = v.vintage
  @vintages[y] = v
  @newest_vintage = y if y > @newest_vintage
end
query(q=Query.new) { |q| ... } click to toggle source
# File lib/rboc/data.rb, line 129
def query(q=Query.new)
  yield q if block_given?
  @vintages[@newest_vintage].query q
end
query_raw(q=Query.new) { |q| ... } click to toggle source
# File lib/rboc/data.rb, line 124
def query_raw(q=Query.new)
  yield q if block_given?
  @vintages[@newest_vintage].query_raw q
end
vintage_years() click to toggle source
# File lib/rboc/data.rb, line 113
def vintage_years
  @vintages.keys
end