Class: Cloudpress::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cloudpress::Post
- Defined in:
- app/models/cloudpress/post.rb
Instance Method Summary collapse
- #layout ⇒ Object
- #metadata ⇒ Object
- #summary ⇒ Object
- #time_to_read ⇒ Object
- #to_param ⇒ Object
- #update_from_dropbox(dropbox_file) ⇒ Object
- #wordcount ⇒ Object
Instance Method Details
#layout ⇒ Object
30 31 32 |
# File 'app/models/cloudpress/post.rb', line 30 def layout [:layout] end |
#metadata ⇒ Object
34 35 36 |
# File 'app/models/cloudpress/post.rb', line 34 def super.with_indifferent_access end |
#summary ⇒ Object
38 39 40 |
# File 'app/models/cloudpress/post.rb', line 38 def summary @summary ||= Nokogiri::HTML(body).at_css('p').text end |
#time_to_read ⇒ Object
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_param ⇒ Object
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 |
#wordcount ⇒ Object
42 43 44 |
# File 'app/models/cloudpress/post.rb', line 42 def wordcount @wordcount ||= Nokogiri::HTML(body).inner_text.split(' ').size end |