Class: RemoteDevJobs::CLI::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_dev_jobs/Job.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_hash) ⇒ Job



7
8
9
10
11
12
# File 'lib/remote_dev_jobs/Job.rb', line 7

def initialize(job_hash)
  job_hash.each do |attr, value|
    self.send("#{attr}=", value)
  end
  @@all << self
end

Instance Attribute Details

#companyObject

Returns the value of attribute company.



3
4
5
# File 'lib/remote_dev_jobs/Job.rb', line 3

def company
  @company
end

#company_siteObject

Returns the value of attribute company_site.



3
4
5
# File 'lib/remote_dev_jobs/Job.rb', line 3

def company_site
  @company_site
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/remote_dev_jobs/Job.rb', line 3

def description
  @description
end

#job_urlObject

Returns the value of attribute job_url.



3
4
5
# File 'lib/remote_dev_jobs/Job.rb', line 3

def job_url
  @job_url
end

#locationObject

Returns the value of attribute location.



3
4
5
# File 'lib/remote_dev_jobs/Job.rb', line 3

def location
  @location
end

#numberObject

Returns the value of attribute number.



3
4
5
# File 'lib/remote_dev_jobs/Job.rb', line 3

def number
  @number
end

#positionObject

Returns the value of attribute position.



3
4
5
# File 'lib/remote_dev_jobs/Job.rb', line 3

def position
  @position
end

#seniorityObject

Returns the value of attribute seniority.



3
4
5
# File 'lib/remote_dev_jobs/Job.rb', line 3

def seniority
  @seniority
end

Class Method Details

.allObject



36
37
38
# File 'lib/remote_dev_jobs/Job.rb', line 36

def self.all
  @@all
end

.create_from_collection(jobs_array) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/remote_dev_jobs/Job.rb', line 14

def self.create_from_collection(jobs_array)
  jobs_array.each_with_index do |job, index|
    if job
      job_hash = {
        number: index + 1,
        company: job[:company],
        location: job[:location],
        position: job[:position],
        seniority: job[:seniority],
        job_url: job[:job_url]
      }
      self.new(job_hash)
    end
  end
end

Instance Method Details

#add_job_attributes(attributes_hash) ⇒ Object



30
31
32
33
34
# File 'lib/remote_dev_jobs/Job.rb', line 30

def add_job_attributes(attributes_hash)
  attributes_hash.each do |attr, value|
    self.send("#{attr}=", value)
  end
end