Class: CV

Inherits:
Object
  • Object
show all
Extended by:
Vitae::Delegators
Defined in:
lib/vitae/cv.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Vitae::Delegators

class_delegate, delegate

Constructor Details

#initialize(yaml_file) ⇒ CV

Returns a new instance of CV.



28
29
30
31
# File 'lib/vitae/cv.rb', line 28

def initialize yaml_file
  @yaml_file = yaml_file
  @file_name = File.basename(yaml_file, '.yaml')
end

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



6
7
8
# File 'lib/vitae/cv.rb', line 6

def file_name
  @file_name
end

Class Method Details

.allObject



9
10
11
12
13
14
15
# File 'lib/vitae/cv.rb', line 9

def all
  raise "Vitae::project_root is not set" unless Vitae::project_root
  cvs = Dir.glob(File.join(Vitae::project_root, "cvs/*.yaml"))
  cvs.map do |cv|
    CV.new(cv)
  end
end

.find(file_name) ⇒ Object



17
18
19
20
21
# File 'lib/vitae/cv.rb', line 17

def find file_name
  all.find do |cv|
    cv.file_name == file_name
  end
end

Instance Method Details

#data_hashObject



46
47
48
# File 'lib/vitae/cv.rb', line 46

def data_hash
  @data_hash ||= (YAML::load_file(@yaml_file) rescue Hash.new)
end

#ga_tracking_idObject



42
43
44
# File 'lib/vitae/cv.rb', line 42

def ga_tracking_id
  vitae_config["ga_tracking_id"]
end


51
52
53
# File 'lib/vitae/cv.rb', line 51

def link
  "/#{file_name}"
end

#nameObject



34
35
36
# File 'lib/vitae/cv.rb', line 34

def name
  @name ||= data_hash.delete("name")
end

#themeObject



55
56
57
# File 'lib/vitae/cv.rb', line 55

def theme
  "default"
end

#to_sObject



59
60
61
# File 'lib/vitae/cv.rb', line 59

def to_s
  name
end

#vitae_configObject



38
39
40
# File 'lib/vitae/cv.rb', line 38

def vitae_config
  @vitae_config ||= data_hash.delete("vitae_config")
end