Sha256: b71d427f7176fb70c816f75ab67b5bcf47ade0e2a584fbccb80434ba37eaf848

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

module FbGraph
  class Work
    include Comparison

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

    def initialize(attributes = {})
      if (employer = attributes[:employer])
        @employer = Page.new(employer.delete(:id), employer)
      end
      if (location = attributes[:location])
        @location = Page.new(location.delete(:id), location)
      end
      if (position = attributes[:position])
        @position = Page.new(position.delete(:id), position)
      end
      @projects = []
      if attributes[:projects]
        attributes[:projects].each do |project|
          @projects << Project.new(project.delete(:id), project)
        end
      end
      if attributes[:start_date] && attributes[:start_date] != '0000-00'
        year, month = attributes[:start_date].split('-').collect(&:to_i)
        @start_date = if month.blank? || 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.blank? || month == 0
          Date.new(year)
        else
          Date.new(year, month)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fb_graph-1.6.1 lib/fb_graph/work.rb
fb_graph-1.6.0 lib/fb_graph/work.rb
fb_graph-1.5.5 lib/fb_graph/work.rb
fb_graph-1.5.4 lib/fb_graph/work.rb
fb_graph-1.5.3 lib/fb_graph/work.rb
fb_graph-1.5.2 lib/fb_graph/work.rb
fb_graph-1.5.1 lib/fb_graph/work.rb
fb_graph-1.5.0 lib/fb_graph/work.rb
fb_graph-1.4.1 lib/fb_graph/work.rb
fb_graph-1.4.0 lib/fb_graph/work.rb
fb_graph-1.3.9 lib/fb_graph/work.rb
fb_graph-1.3.8 lib/fb_graph/work.rb
fb_graph-1.3.7 lib/fb_graph/work.rb