Sha256: 7e1d7114ba3eb96c2cdbfe43bcb36d715392acffbc3c65bc06b6fd6e75780a24

Contents?: true

Size: 839 Bytes

Versions: 7

Compression:

Stored size: 839 Bytes

Contents

module LinkedIn
  class Publications < LinkedIn::Base

    def publications
      @publications ||= @doc.children.inject([]) do |list, publication|
        list << Resource.new(publication) unless publication.blank?
        list
      end
    end

    class Resource
      def initialize(publication)
        @publication = publication
      end

      %w[id title].each do |f|
        define_method(f.to_sym) do
          @publication.xpath("./#{f.gsub(/_/,'-')}").text
        end
      end

      def year
        @year ||= @publication.xpath("./date/year").text.to_i
      end

      def day
        @day ||= @publication.xpath("./date/day").text.to_i
      end

      def month
        @month ||= @publication.xpath("./date/month").text.to_i
      end

      def date
        Date.civil(year, month, day)
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
linkedin-bdigital-0.2.2.3 lib/linked_in/publications.rb
cl_linkedin-0.2.3 lib/linked_in/publications.rb
linkedin-bdigital-0.2.2.2 lib/linked_in/publications.rb
linkedin-bdigital-0.2.2.1 lib/linked_in/publications.rb
linkedin-bdigital-0.2.2 lib/linked_in/publications.rb
linkedin-0.2.2 lib/linked_in/publications.rb
linkedin-0.2.1 lib/linked_in/publications.rb