Sha256: df4acf3d89cd01c102c63e9bd3bb4ceb45e9806854836c8cd3a7bb43e07b8906

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

module GovKit::ActsAsCiteable

  def self.included(base)
    base.extend ActMethods
  end

  module ActMethods
    def acts_as_citeable(options={})
      options[:keywords] ||= []

      class_inheritable_accessor :options
      self.options = options

      unless included_modules.include? InstanceMethods
        extend ClassMethods
        include InstanceMethods
      end
    end
  end

  module ClassMethods
  end

  module InstanceMethods

    def raw_citations
      params = self.options[:keywords].clone
      attributes = self.options[:with].clone

      attributes.each do |attr|
        params << self.instance_eval("#{attr}")
      end
      {
        :google_news => GovKit::SearchEngines::GoogleNews.search(params),
        :google_blogs => GovKit::SearchEngines::GoogleBlog.search(params),
        :technorati => GovKit::SearchEngines::Technorati.search(params)
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
govkit-0.1.0 lib/gov_kit/acts_as_citeable.rb