Class: Career

Inherits:
Object
  • Object
show all
Defined in:
lib/nexmo_developer/app/presenters/career.rb

Constant Summary collapse

HEADING_TAG_LIST =
%w[h1 h2 h3 h4 h5 h6].freeze
DEPARTMENTS =
YAML.safe_load(File.read("#{Rails.configuration.docs_base_path}/config/greenhouse_departments.yml"))

Instance Method Summary collapse

Constructor Details

#initialize(career) ⇒ Career

Returns a new instance of Career.



5
6
7
# File 'lib/nexmo_developer/app/presenters/career.rb', line 5

def initialize(career)
  @career = career
end

Instance Method Details

#department_codesObject



17
18
19
# File 'lib/nexmo_developer/app/presenters/career.rb', line 17

def department_codes
  @department_codes ||= @career[:departments].pluck(:id) # rubocop:disable Rails/PluckId
end

#descriptionObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/nexmo_developer/app/presenters/career.rb', line 21

def description
  content = CGI.unescapeHTML(@career[:content])

  # If it starts with a header, strip it out
  document = Nokogiri::HTML::DocumentFragment.parse(content)
  first_child = document.children[0]
  first_child.remove if HEADING_TAG_LIST.include?(first_child.name)

  document.to_html
end

#devrel?Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/nexmo_developer/app/presenters/career.rb', line 36

def devrel?
  @career[:departments].any? { |d| d[:id] == Greenhouse::DEPARTMENT_ID } &&
    @career[:title].downcase.match?(Regexp.union(Greenhouse::TITLES))
end

#locationObject



13
14
15
# File 'lib/nexmo_developer/app/presenters/career.rb', line 13

def location
  @career.dig(:location, :name)
end

#titleObject



9
10
11
# File 'lib/nexmo_developer/app/presenters/career.rb', line 9

def title
  @career[:title]
end

#urlObject



32
33
34
# File 'lib/nexmo_developer/app/presenters/career.rb', line 32

def url
  @career[:absolute_url]
end