Sha256: a65f98da531a305594067884e6f824f9c662e6cd36f84d59116be304ad844376

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

module FbGraph
  class Work
    include 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

17 entries across 17 versions & 2 rubygems

Version Path
fb_graph-1.2.1 lib/fb_graph/work.rb
fb_graph-1.2.0 lib/fb_graph/work.rb
fb_graph-1.1.7 lib/fb_graph/work.rb
fb_graph-1.1.6 lib/fb_graph/work.rb
fb_graph-1.1.5 lib/fb_graph/work.rb
fb_graph-1.1.4 lib/fb_graph/work.rb
fb_graph-1.1.3 lib/fb_graph/work.rb
fb_graph-1.1.2 lib/fb_graph/work.rb
fb_graph-1.1.1 lib/fb_graph/work.rb
fb_graph-1.1.0 lib/fb_graph/work.rb
fb_graph-1.0.7 lib/fb_graph/work.rb
fb_graph-1.0.6 lib/fb_graph/work.rb
fb_graph-1.0.5 lib/fb_graph/work.rb
palidanx-fb_graph-1.0.4 lib/fb_graph/work.rb
fb_graph-1.0.4 lib/fb_graph/work.rb
fb_graph-1.0.3 lib/fb_graph/work.rb
fb_graph-1.0.2 lib/fb_graph/work.rb