Class: Cloudpress::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/cloudpress/post.rb

Instance Method Summary collapse

Instance Method Details

#layoutObject



30
31
32
# File 'app/models/cloudpress/post.rb', line 30

def layout
  [:layout]
end

#metadataObject



34
35
36
# File 'app/models/cloudpress/post.rb', line 34

def 
  super.with_indifferent_access
end

#summaryObject



38
39
40
# File 'app/models/cloudpress/post.rb', line 38

def summary
  @summary   ||= Nokogiri::HTML(body).at_css('p').text
end

#time_to_readObject



46
47
48
# File 'app/models/cloudpress/post.rb', line 46

def time_to_read
  @time_to_read ||= ((wordcount.to_f / 200.0) * 60).to_i
end

#to_paramObject



26
27
28
# File 'app/models/cloudpress/post.rb', line 26

def to_param
  slug
end

#update_from_dropbox(dropbox_file) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/cloudpress/post.rb', line 13

def update_from_dropbox(dropbox_file)
  self.revision     = dropbox_file.revision
  self.body         = dropbox_file.body
  self.     = dropbox_file.
  self.title        = [:title] || titleized_file_name
  self.publish_date = created_at || Time.now
  self.publish_date = Time.parse([:publish_date]) if [:publish_date]
  self.slug         = [:slug] || generate_slug
  self.tag_list     = .map(&:downcase)
  self.state        = dropbox_file.state
  save!
end

#wordcountObject



42
43
44
# File 'app/models/cloudpress/post.rb', line 42

def wordcount
  @wordcount ||= Nokogiri::HTML(body).inner_text.split(' ').size
end