Class: RemoteOK::Job
- Inherits:
-
Object
- Object
- RemoteOK::Job
- Defined in:
- lib/remoteok/job.rb
Overview
Class representing a single job from RemoteOK with data accessors.
Constant Summary collapse
- HTML_CHARS_REGEX =
/<("[^"]*"|'[^']*'|[^'">])*>/
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #apply_url ⇒ Object
- #company ⇒ Object
- #company_logo ⇒ Object
- #date ⇒ Object
- #description ⇒ Object
- #description_text ⇒ Object
- #epoch ⇒ Object
- #id ⇒ Object
-
#initialize(job_data) ⇒ Job
constructor
A new instance of Job.
- #location ⇒ Object
- #logo ⇒ Object
- #original ⇒ Object
- #position ⇒ Object
- #slug ⇒ Object
- #tags ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(job_data) ⇒ Job
Returns a new instance of Job.
12 13 14 |
# File 'lib/remoteok/job.rb', line 12 def initialize(job_data) @raw = job_data end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/remoteok/job.rb', line 8 def raw @raw end |
Instance Method Details
#apply_url ⇒ Object
84 85 86 |
# File 'lib/remoteok/job.rb', line 84 def apply_url raw["apply_url"] end |
#company ⇒ Object
38 39 40 |
# File 'lib/remoteok/job.rb', line 38 def company raw["company"] end |
#company_logo ⇒ Object
42 43 44 |
# File 'lib/remoteok/job.rb', line 42 def company_logo raw["company_logo"] end |
#date ⇒ Object
32 33 34 35 36 |
# File 'lib/remoteok/job.rb', line 32 def date return unless raw["date"] DateTime.parse raw["date"] end |
#description ⇒ Object
62 63 64 |
# File 'lib/remoteok/job.rb', line 62 def description raw["description"] end |
#description_text ⇒ Object
66 67 68 69 70 |
# File 'lib/remoteok/job.rb', line 66 def description_text return unless raw["description"] raw["description"].gsub(HTML_CHARS_REGEX, " ").strip.gsub(/\s+/, " ") end |
#epoch ⇒ Object
26 27 28 29 30 |
# File 'lib/remoteok/job.rb', line 26 def epoch return unless raw["epoch"] Integer raw["epoch"] end |
#id ⇒ Object
20 21 22 23 24 |
# File 'lib/remoteok/job.rb', line 20 def id return unless raw["id"] Integer raw["id"] end |
#location ⇒ Object
72 73 74 |
# File 'lib/remoteok/job.rb', line 72 def location raw["location"] end |
#logo ⇒ Object
58 59 60 |
# File 'lib/remoteok/job.rb', line 58 def logo raw["logo"] end |
#original ⇒ Object
76 77 78 |
# File 'lib/remoteok/job.rb', line 76 def original raw["original"] end |
#position ⇒ Object
46 47 48 |
# File 'lib/remoteok/job.rb', line 46 def position raw["position"] end |
#slug ⇒ Object
16 17 18 |
# File 'lib/remoteok/job.rb', line 16 def slug raw["slug"] end |
#tags ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/remoteok/job.rb', line 50 def return unless raw["tags"] raw["tags"].map do |tag| tag.tr(" ", "_").to_sym end end |
#url ⇒ Object
80 81 82 |
# File 'lib/remoteok/job.rb', line 80 def url raw["url"] end |