Sha256: f94fc7b99b2f1185c725932a70bc6bcbcf8d493668dac9f1e69dadcc9c85ca07
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
require 'discoverer' module Fetcher class Microdata include Discoverer::Writer include Virtus attr_reader :_type def initialize *arguments if arguments.first.is_a? Symbol social_network = arguments.shift self.attributes = coerce social_network, *arguments elsif arguments.first.is_a? Hash self.attributes = arguments.first end end def coerce social_network, *raw_data begin eval("::#{self.class}::#{social_network.to_s.capitalize}::Coercer").call *raw_data rescue NameError => e if e.message.include? "#{self.class}::#{social_network.to_s.capitalize}" raise UnknownSocialNetworkError, "Couldn't find coertion algorithm for '#{social_network}' social network, please require 'fetcher-microdata-#{social_network}' in your project and make sure it has a #{self.class}::#{social_network.to_s.capitalize}::Coercer" else raise e end end end # Exceptions ####################################### class UnknownSocialNetworkError < StandardError; end end end require 'fetcher-microdata/version' require 'fetcher-microdata/person_user' require 'fetcher-microdata/article_small' require 'fetcher-microdata/review' require 'fetcher-microdata/user_comments' require 'writer/fetcher-microdata/person_user' require 'writer/fetcher-microdata/article_small' require 'writer/fetcher-microdata/review' require 'writer/fetcher-microdata/user_comments'
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fetcher-microdata-0.0.13 | lib/fetcher-microdata.rb |
fetcher-microdata-0.0.12 | lib/fetcher-microdata.rb |
fetcher-microdata-0.0.11 | lib/fetcher-microdata.rb |