Sha256: 2b26435ca7433b7cf65a59d86a599c693b8bc714554fdd9c6b379691145d5b72

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

module FbGraph
  class Work
    include FbGraph::Comparison

    attr_accessor :employer, :location, :position, :start_date, :end_date

    def initialize(attributes = {})
      if (employer = attributes[:employer])
        @employer = FbGraph::Page.new(employer.delete(:id), employer)
      end
      if (location = attributes[:location])
        @location = FbGraph::Page.new(location.delete(:id), location)
      end
      if (position = attributes[:position])
        @position = FbGraph::Page.new(position.delete(:id), position)
      end
      if attributes[:start_date] && attributes[:start_date] != '0000-00'
        year, month = attributes[:start_date].split('-').collect(&:to_i)
        @start_date = if month == 0
          Date.new(year)
        else
          Date.new(year, month)
        end
      end
      if attributes[:end_date] && attributes[:end_date] != '0000-00'
        year, month = attributes[:end_date].split('-').collect(&:to_i)
        @end_date = if month == 0
          Date.new(year)
        else
          Date.new(year, month)
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fb_graph-1.0.1 lib/fb_graph/work.rb
fb_graph-1.0.0 lib/fb_graph/work.rb
fb_graph-0.8.0 lib/fb_graph/work.rb
fb_graph-0.7.3 lib/fb_graph/work.rb
fb_graph-0.7.2 lib/fb_graph/work.rb
fb_graph-0.7.1 lib/fb_graph/work.rb
fb_graph-0.7.0 lib/fb_graph/work.rb
fb_graph-0.6.0 lib/fb_graph/work.rb
fb_graph-0.5.0 lib/fb_graph/work.rb
fb_graph-0.4.2 lib/fb_graph/work.rb
fb_graph-0.4.1 lib/fb_graph/work.rb
fb_graph-0.4.0 lib/fb_graph/work.rb
fb_graph-0.3.0 lib/fb_graph/work.rb
fb_graph-0.2.2 lib/fb_graph/work.rb
fb_graph-0.2.1 lib/fb_graph/work.rb
fb_graph-0.2.0 lib/fb_graph/work.rb
fb_graph-0.1.3 lib/fb_graph/work.rb
fb_graph-0.1.2 lib/fb_graph/work.rb