Sha256: 955996c4ca3cbeb11336475957bfeb48f29e24ea68125b49a61fac0d69b6c54a

Contents?: true

Size: 875 Bytes

Versions: 10

Compression:

Stored size: 875 Bytes

Contents

module ContactData
  class Text
    class Results
      extend ContactData

      attr_reader :text, :params, :raw

      BASE = :text

      def initialize(t, p = {})
        @text = t
        @params = p

        @raw = Fetcher.post :search, params.to_options(BASE, text)
      end

      def contacts
        @contacts ||= raw[:contacts]
      end

      def emails
        @emails ||= raw[:emails]
      end

      def slugs
        @slugs ||= contacts.map { |c| c[:slug] }
      end

      def mentions
        @mentions ||= raw[:mentions]
      end

      def slugs_and_mentions
        @slugs_and_mentions ||= (slugs | mentions)
      end

      def title_contacts
        @title_contacts ||= contacts.select { |c| c[:in_title] }
      end

      def title_contact_slugs
        @title_contact_slugs ||= title_contacts.map { |c| c[:slug] }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
contact-data-0.4.9 lib/contact-data/text/results.rb
contact-data-0.4.8 lib/contact-data/text/results.rb
contact-data-0.4.6 lib/contact-data/text/results.rb
contact-data-0.4.5 lib/contact-data/text/results.rb
contact-data-0.4.4 lib/contact-data/text/results.rb
contact-data-0.4.3 lib/contact-data/text/results.rb
contact-data-0.4.2 lib/contact-data/text/results.rb
contact-data-0.4.1 lib/contact-data/text/results.rb
contact-data-0.3.4 lib/contact-data/text/results.rb
contact-data-0.4.0 lib/contact-data/text/results.rb