Class: Jobless::Document
- Inherits:
-
Object
- Object
- Jobless::Document
- Defined in:
- lib/document.rb
Constant Summary collapse
- PERSONAL_ATTRIBUTES =
%w( name email location address homepage )
- GROUP_NAMES =
%w( employment education open_source other_experience )
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
Instance Method Summary collapse
- #css ⇒ Object
- #group(name, &block) ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #stylesheet(file_path) ⇒ Object
- #template(template) ⇒ Object
- #write_to_file(filename) ⇒ Object
Constructor Details
#initialize ⇒ Document
Returns a new instance of Document.
23 24 25 26 27 28 |
# File 'lib/document.rb', line 23 def initialize @data = {} @groups = [] @template = File.("../template/template.html.erb", __FILE__) @stylesheet = File.("../template/style.css", __FILE__) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/document.rb', line 6 def data @data end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
6 7 8 |
# File 'lib/document.rb', line 6 def groups @groups end |
Instance Method Details
#css ⇒ Object
61 62 63 |
# File 'lib/document.rb', line 61 def css File.read(@stylesheet) end |
#group(name, &block) ⇒ Object
41 42 43 44 45 |
# File 'lib/document.rb', line 41 def group(name, &block) group = Group.new(name) group.instance_eval &block @groups.push group end |
#stylesheet(file_path) ⇒ Object
57 58 59 |
# File 'lib/document.rb', line 57 def stylesheet(file_path) @stylesheet = file_path end |
#template(template) ⇒ Object
53 54 55 |
# File 'lib/document.rb', line 53 def template(template) @template = template end |
#write_to_file(filename) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/document.rb', line 65 def write_to_file(filename) renderer = ERB.new(File.read(@template)) generated_html = renderer.result(binding) File.open(filename, 'w') do |file| file.write(generated_html) end end |