Sha256: ab7f7a6d5043ec98e1c3c1d259662a89a0de15db1a41a723e7266514e78dad06
Contents?: true
Size: 686 Bytes
Versions: 3
Compression:
Stored size: 686 Bytes
Contents
require 'share_progress' require 'share_progress/errors' require 'share_progress/email_variant' require 'share_progress/facebook_variant' require 'share_progress/twitter_variant' module ShareProgress class VariantParser def self.parse(hash_to_parse) keys = hash_to_parse.keys.map(&:to_sym) match = nil [FacebookVariant, EmailVariant, TwitterVariant].each do |variant_class| if (keys & variant_class.fields).size > 0 # & is array intersection raise CouldNotParseVariant unless match.nil? # only match one class match = variant_class end end raise CouldNotParseVariant if match.nil? match end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
share_progress-0.1.2 | lib/share_progress/variant_parser.rb |
share_progress-0.1.1 | lib/share_progress/variant_parser.rb |
share_progress-0.1.0 | lib/share_progress/variant_parser.rb |