Class: WeWorkRemotely::Job
- Inherits:
-
Object
- Object
- WeWorkRemotely::Job
- Defined in:
- lib/weworkremotely/job.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#company ⇒ Object
Returns the value of attribute company.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#published_date ⇒ Object
Returns the value of attribute published_date.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id: nil, company: nil, name: nil, description: nil, published_date: nil, url: nil, category: nil) ⇒ Job
constructor
A new instance of Job.
Constructor Details
#initialize(id: nil, company: nil, name: nil, description: nil, published_date: nil, url: nil, category: nil) ⇒ Job
Returns a new instance of Job.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/weworkremotely/job.rb', line 6 def initialize(id: nil, company: nil, name: nil, description: nil, published_date: nil, url: nil, category: nil) @id = id if id @name = name @published_date = published_date if published_date @url = url if url @description = description if description @company = WeWorkRemotely::Company.find_or_create_by_name(company) if company @company.add_job(self) @category = WeWorkRemotely::Category.find_or_create_by_name(category) if category @category.add_job(self) @@all << self end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
2 3 4 |
# File 'lib/weworkremotely/job.rb', line 2 def category @category end |
#company ⇒ Object
Returns the value of attribute company.
2 3 4 |
# File 'lib/weworkremotely/job.rb', line 2 def company @company end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/weworkremotely/job.rb', line 2 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/weworkremotely/job.rb', line 2 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/weworkremotely/job.rb', line 2 def name @name end |
#published_date ⇒ Object
Returns the value of attribute published_date.
2 3 4 |
# File 'lib/weworkremotely/job.rb', line 2 def published_date @published_date end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/weworkremotely/job.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
19 20 21 |
# File 'lib/weworkremotely/job.rb', line 19 def self.all @@all end |
.destroy_all ⇒ Object
27 28 29 |
# File 'lib/weworkremotely/job.rb', line 27 def self.destroy_all @@all.clear end |
.find_by_id(id) ⇒ Object
23 24 25 |
# File 'lib/weworkremotely/job.rb', line 23 def self.find_by_id(id) self.all.detect { |job| job.id == id } end |