Class: FsTemplate::TemplateFile
- Inherits:
-
Object
- Object
- FsTemplate::TemplateFile
- Defined in:
- lib/fs_template/template_file.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#full_body ⇒ Object
Returns the value of attribute full_body.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #apply_body_to(base_body) ⇒ Object
- #combined(base) ⇒ Object
- #split_note_and_body ⇒ Object
- #write_to!(dir) ⇒ Object
Methods included from NewWay
#apply_body_to_long, #note_params, #split_note_and_body_long
Methods included from OldWay
#apply_body_to_short, #split_note_and_body_short
Instance Attribute Details
#full_body ⇒ Object
Returns the value of attribute full_body.
4 5 6 |
# File 'lib/fs_template/template_file.rb', line 4 def full_body @full_body end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/fs_template/template_file.rb', line 4 def path @path end |
Instance Method Details
#apply_body_to(base_body) ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/fs_template/template_file.rb', line 98 def apply_body_to(base_body) if note.present? m = "apply_body_to_#{format}" send(m,base_body) else body end end |
#combined(base) ⇒ Object
109 110 111 |
# File 'lib/fs_template/template_file.rb', line 109 def combined(base) self.class.new(:path => path, :full_body => apply_body_to(base.body)) end |
#split_note_and_body ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/fs_template/template_file.rb', line 84 def split_note_and_body [:split_note_and_body_short,:split_note_and_body_long].each do |meth| res = send(meth) return res if res end {:note => nil, :body => full_body} end |
#write_to!(dir) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/fs_template/template_file.rb', line 113 def write_to!(dir) raise "bad path" if path.blank? d = File.dirname("#{dir}/#{path}") `mkdir -p #{d}` File.create "#{dir}/#{path}",body end |