Sha256: 93ea2fd213edba891e634764ff1c2716279b38754b4edb5aa04acae1e8583566

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

module Sniffles
  module Sniffers
    class FacebookInsights
      include Text
      
      attr_accessor :doc
      attr_reader :output
      
      def initialize(response_body)
        @output = {}        
        parse(response_body) && process_document
      end
      
      def process_document
        if @output[:found] = found?
          parse_extra_details
        end
      end
      
      private
      def found?
        match?(/property="fb:(admins|app_id|page_id)"/i)
      end
      
      def parse_extra_details
        @output[:admin_ids] = capture(/property="fb:admins" content="((\d+)(,\s*\d+)*)"/)
        @output[:app_id] = capture(/"fb:app_id" content="([\d]+)"/)
        @output[:page_id] = capture(/"fb:page_id" content="([\d]+)"/)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sniffles-0.1.5 lib/sniffles/sniffers/analytics/facebook_insights.rb