Class: RemoteOK::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/remoteok/job.rb

Overview

Class representing a single job from RemoteOK with data accessors.

Constant Summary collapse

HTML_CHARS_REGEX =
/<("[^"]*"|'[^']*'|[^'">])*>/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#rawObject (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_urlObject



84
85
86
# File 'lib/remoteok/job.rb', line 84

def apply_url
  raw['apply_url']
end

#companyObject



38
39
40
# File 'lib/remoteok/job.rb', line 38

def company
  raw['company']
end

#company_logoObject



42
43
44
# File 'lib/remoteok/job.rb', line 42

def 
  raw['company_logo']
end

#dateObject



32
33
34
35
36
# File 'lib/remoteok/job.rb', line 32

def date
  return unless raw['date']

  DateTime.parse raw['date']
end

#descriptionObject



62
63
64
# File 'lib/remoteok/job.rb', line 62

def description
  raw['description']
end

#description_textObject



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

#epochObject



26
27
28
29
30
# File 'lib/remoteok/job.rb', line 26

def epoch
  return unless raw['epoch']

  Integer raw['epoch']
end

#idObject



20
21
22
23
24
# File 'lib/remoteok/job.rb', line 20

def id
  return unless raw['id']

  Integer raw['id']
end

#locationObject



72
73
74
# File 'lib/remoteok/job.rb', line 72

def location
  raw['location']
end

#logoObject



58
59
60
# File 'lib/remoteok/job.rb', line 58

def 
  raw['logo']
end

#originalObject



76
77
78
# File 'lib/remoteok/job.rb', line 76

def original
  raw['original']
end

#positionObject



46
47
48
# File 'lib/remoteok/job.rb', line 46

def position
  raw['position']
end

#slugObject



16
17
18
# File 'lib/remoteok/job.rb', line 16

def slug
  raw['slug']
end

#tagsObject



50
51
52
53
54
55
56
# File 'lib/remoteok/job.rb', line 50

def tags
  return unless raw['tags']

  raw['tags'].map do |tag|
    tag.gsub(' ', '_').to_sym
  end
end

#urlObject



80
81
82
# File 'lib/remoteok/job.rb', line 80

def url
  raw['url']
end