Class: Jepeto::JekyllPost
- Inherits:
-
Object
- Object
- Jepeto::JekyllPost
- Includes:
- JekyllPostHelper
- Defined in:
- lib/jepeto/jekyll_post.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ JekyllPost
constructor
A new instance of JekyllPost.
- #save! ⇒ Object
Methods included from JekyllPostHelper
Constructor Details
#initialize(options) ⇒ JekyllPost
Returns a new instance of JekyllPost.
28 29 30 31 |
# File 'lib/jepeto/jekyll_post.rb', line 28 def initialize() define_instance_variables! @options = () end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'lib/jepeto/jekyll_post.rb', line 26 def @options end |
Instance Method Details
#save! ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/jepeto/jekyll_post.rb', line 47 def save! Dir.chdir('..') if Dir.getwd.include?(Jepeto::POST_DIRECTORY) post_file = File.join(Jepeto::POST_DIRECTORY, self.filename) unless File.writable?(Jepeto::POST_DIRECTORY) raise "The post directory is not wriatble" exit end if File.exists?(post_file) raise NameError, "A post file with the same name already exists" exit end File.open(post_file, 'w') do |file| file.puts yaml_front_matter end File.(post_file) end |