Class: LocalUnfuddleNotebook::Page

Inherits:
Valuable
  • Object
show all
Defined in:
lib/local_unfuddle_notebook/page.rb

Instance Method Summary collapse

Instance Method Details

#basenameObject



12
13
14
# File 'lib/local_unfuddle_notebook/page.rb', line 12

def basename
  "#{title.gsub(/\W/, '-')}.yaml".downcase
end

#changed?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/local_unfuddle_notebook/page.rb', line 16

def changed?
  notebook.last_updated_at < local_file.mtime
end

#local_attributesObject



20
21
22
23
24
25
26
# File 'lib/local_unfuddle_notebook/page.rb', line 20

def local_attributes
  {
    :body => body,
    :id => id,
    :title => title
  }
end

#pushObject



28
29
30
# File 'lib/local_unfuddle_notebook/page.rb', line 28

def push
  notebook["/pages/#{id}"].put :page => remote_attributes
end

#remote_attributesObject



32
33
34
35
36
37
38
# File 'lib/local_unfuddle_notebook/page.rb', line 32

def remote_attributes
  {
    :title => title,
    :body => body,
    :message => message
  }
end

#saveObject



40
41
42
# File 'lib/local_unfuddle_notebook/page.rb', line 40

def save
  (Pow(Notebook.local_pages_path)/basename).write(local_attributes.to_yaml)
end