Class: DigitalNomadJobs::Company

Inherits:
Object
  • Object
show all
Defined in:
lib/digital_nomad_jobs/company.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Company

Returns a new instance of Company.



7
8
9
10
11
# File 'lib/digital_nomad_jobs/company.rb', line 7

def initialize(name)
  @name = name 
  @jobs = []
  @@all << self 
end

Instance Attribute Details

#company_urlObject

Returns the value of attribute company_url.



4
5
6
# File 'lib/digital_nomad_jobs/company.rb', line 4

def company_url
  @company_url
end

#jobsObject (readonly)

Returns the value of attribute jobs.



5
6
7
# File 'lib/digital_nomad_jobs/company.rb', line 5

def jobs
  @jobs
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/digital_nomad_jobs/company.rb', line 4

def name
  @name
end

Class Method Details

.allObject



25
26
27
# File 'lib/digital_nomad_jobs/company.rb', line 25

def self.all
  @@all
end

.create_by_name(name) ⇒ Object



17
18
19
# File 'lib/digital_nomad_jobs/company.rb', line 17

def self.create_by_name(name)
  company = self.new(name)
end

.find_by_name(name) ⇒ Object



13
14
15
# File 'lib/digital_nomad_jobs/company.rb', line 13

def self.find_by_name(name)
  @@all.find {|company| company.name == name}
end

.find_or_create_by_name(name) ⇒ Object



21
22
23
# File 'lib/digital_nomad_jobs/company.rb', line 21

def self.find_or_create_by_name(name)
  find_by_name(name) || create_by_name(name)
end

.list_companiesObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/digital_nomad_jobs/company.rb', line 38

def self.list_companies 
  puts ""
  puts "============ COMPANIES NOW HIRING! =============".blue 
  puts "================================================".blue 
  puts ""
  all.each.with_index(1) do |company, i| 
    puts "#{i}. #{company.name}"
  end 
  puts "================================================".blue 
end

.resetObject



29
30
31
# File 'lib/digital_nomad_jobs/company.rb', line 29

def self.reset
  @@all.clear
end

Instance Method Details

#add_job(job) ⇒ Object



33
34
35
36
# File 'lib/digital_nomad_jobs/company.rb', line 33

def add_job(job)
  @jobs << job 
  job.company = self.name 
end


49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/digital_nomad_jobs/company.rb', line 49

def print_company_jobs
  puts ""
  puts "#{self.name.upcase} IS LOOKING TO FILL THESE POSITIONS!".white.on_blue 
  puts "-----------------------------------------------------------------------------------------------".blue 
  jobs.each.with_index(1) do |job, i| 
    puts "#{i}. #{job.title} - Posted:#{job.time_posted} Ago"
    puts ""
    puts "About: ".blue + "#{job.description}"
    puts ""
    puts "TO APPLY OR SEE MORE FROM #{self.name.upcase} VISIT: ".blue + "#{'https://remoteok.io' + self.company_url}"
    puts "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -".blue 
  end
  puts "-----------------------------------------------------------------------------------------------".blue 
end