Class: JobEngine::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/job_engine/position.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Position

Returns a new instance of Position.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/job_engine/position.rb', line 12

def initialize(data)
  @featured = data[:featured]

  @path = data[:path]
  @source_path = data[:source_path]
  @updated_at = data[:updated_at]
  @source_url = data[:source_url]
  @title = data[:title]
  @type = data[:type]
  @company = data[:company]
  @company_url = data[:company_url]
  @location = data[:location]
end

Instance Attribute Details

#companyObject (readonly)

Returns the value of attribute company.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def company
  @company
end

#company_urlObject (readonly)

Returns the value of attribute company_url.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def company_url
  @company_url
end

Returns the value of attribute featured.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def featured
  @featured
end

#locationObject (readonly)

Returns the value of attribute location.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def location
  @location
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def path
  @path
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def source_path
  @source_path
end

#source_urlObject (readonly)

Returns the value of attribute source_url.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def source_url
  @source_url
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def type
  @type
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



10
11
12
# File 'lib/job_engine/position.rb', line 10

def updated_at
  @updated_at
end

Class Method Details

.nullObject



6
7
8
# File 'lib/job_engine/position.rb', line 6

def self.null
  OpenStruct.new
end

Instance Method Details

#absolute_pathObject



42
43
44
# File 'lib/job_engine/position.rb', line 42

def absolute_path
  "/#@path"
end

#featured?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/job_engine/position.rb', line 38

def featured?
  !!@featured
end

#guidObject



26
27
28
# File 'lib/job_engine/position.rb', line 26

def guid
  @guid ||= File.basename(path).split('.').first
end

#has_source_url?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/job_engine/position.rb', line 46

def has_source_url?
  !!@source_url
end

#page_titleObject Also known as: atom_title



30
31
32
33
34
# File 'lib/job_engine/position.rb', line 30

def page_title
  if title && company
    "#{title} at #{company}"
  end
end

#source_hostnameObject



50
51
52
53
54
55
# File 'lib/job_engine/position.rb', line 50

def source_hostname
  if has_source_url?
    uri = URI.parse(@source_url)
    uri.hostname
  end
end