class Timebomb::BombFile
Handles reading and writing to a Timebomb
file `*.tb`.
Constants
- EXTENSION
Attributes
bomb[R]
path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/timebomb.rb, line 175 def initialize(path) @path = Pathname.new(path) @bomb = Bomb.new end
Public Instance Methods
read()
click to toggle source
# File lib/timebomb.rb, line 180 def read File.open(path, 'r') do |file| data = file.read frontmatter = Frontmatter.new(data) bomb.title = frontmatter.data.fetch("title") bomb.date = frontmatter.data.fetch("date") bomb.description = frontmatter.body end end
write()
click to toggle source
# File lib/timebomb.rb, line 190 def write data = { "title" => bomb.title, "date" => bomb.date } File.open(path, 'w') do |file| file.puts data.to_yaml file.puts "---" file.puts file.puts bomb.description end end