class Fech::Comparison

Fech::Comparison takes two Filing objects and does comparisons on them, checking for differences between an original and amended filing, or two filings covering the same period in different years.

Attributes

filing_1[RW]
filing_2[RW]

Public Class Methods

new(filing_1, filing_2, opts={}) click to toggle source

Create a new Comparison object by passing in two Filing objects Filing objects need to be downloaded first f1 = Fech::Filing.new(767437) f1.download f2 = Fech::Filing.new(751798) f2.download comparison = Fech::Comparison.new(f1, f2) comparison.summary

# File lib/fech/comparison.rb, line 16
def initialize(filing_1, filing_2, opts={})
  @filing_1     = filing_1
  @filing_2     = filing_2
end

Public Instance Methods

schedule(schedule) click to toggle source

compares a schedule of itemized records from one filing to another returns an array of records that are new or have changed.

# File lib/fech/comparison.rb, line 31
def schedule(schedule)
  @filing_1.rows_like(schedule.to_sym) - @filing_2.rows_like(schedule.to_sym)
end
summary() click to toggle source

compares summary of this filing with summary of an earlier or later version of the filing, returning a Fech::Mapped hash of mapped fields whose values have changed. based on rails' hash diff: github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/diff.rb

# File lib/fech/comparison.rb, line 25
def summary
  @filing_1.summary.delete_if { |k, v| @filing_2.summary[k] == v }.merge!(@filing_2.summary.dup.delete_if { |k, v| @filing_1.summary.has_key?(k) })
end