Class: Droom::Scrap
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Droom::Scrap
- Defined in:
- app/models/droom/scrap.rb
Instance Method Summary collapse
- #as_search_result ⇒ Object
- #next_older ⇒ Object
- #next_younger ⇒ Object
- #text_size ⇒ Object
- #url_with_protocol ⇒ Object
- #url_without_protocol ⇒ Object
- #wordiness ⇒ Object
Instance Method Details
#as_search_result ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'app/models/droom/scrap.rb', line 74 def as_search_result { :type => 'scrap', :prompt => name, :value => name, :id => id } end |
#next_older ⇒ Object
87 88 89 |
# File 'app/models/droom/scrap.rb', line 87 def next_older Droom::Scrap.earlier_than(self).first end |
#next_younger ⇒ Object
83 84 85 |
# File 'app/models/droom/scrap.rb', line 83 def next_younger Droom::Scrap.later_than(self).first end |
#text_size ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/models/droom/scrap.rb', line 58 def text_size if l = body.length ((560.0/(1.4 * l+150.0)) + 0.25) / 1.5 else 1 end end |
#url_with_protocol ⇒ Object
66 67 68 |
# File 'app/models/droom/scrap.rb', line 66 def url_with_protocol body =~ /^https?:\/\// ? body : "http://#{body}" end |
#url_without_protocol ⇒ Object
70 71 72 |
# File 'app/models/droom/scrap.rb', line 70 def url_without_protocol body.sub(/^https?:\/\//, '') end |
#wordiness ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/droom/scrap.rb', line 46 def wordiness if body.length < 48 'word' elsif body.length < 320 'phrase' elsif body.length < 800 'paragraph' else 'text' end end |