Class: Career
- Inherits:
-
Object
- Object
- Career
- 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
- #department_codes ⇒ Object
- #description ⇒ Object
- #devrel? ⇒ Boolean
-
#initialize(career) ⇒ Career
constructor
A new instance of Career.
- #location ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
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_codes ⇒ Object
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 |
#description ⇒ Object
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
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 |
#location ⇒ Object
13 14 15 |
# File 'lib/nexmo_developer/app/presenters/career.rb', line 13 def location @career.dig(:location, :name) end |
#title ⇒ Object
9 10 11 |
# File 'lib/nexmo_developer/app/presenters/career.rb', line 9 def title @career[:title] end |
#url ⇒ Object
32 33 34 |
# File 'lib/nexmo_developer/app/presenters/career.rb', line 32 def url @career[:absolute_url] end |