Module: API::Story::ReadingTime
- Extended by:
- ActiveSupport::Concern
- Included in:
- API::Story
- Defined in:
- lib/quintype/api/story/reading_time.rb
Constant Summary collapse
- WORDS_PER_MINUTE =
275
- SLOW_IMAGE_LIMIT =
10
- INITIAL_IMAGE_READ_TIME =
12
- FINAL_IMAGE_READ_TIME =
3
- ESTIMATED_TWEET_WORDS =
30
Instance Method Summary collapse
Instance Method Details
#time_in_minutes ⇒ Object
11 12 13 |
# File 'lib/quintype/api/story/reading_time.rb', line 11 def time_in_minutes (time_in_seconds.to_f/60).ceil end |
#time_in_seconds ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/quintype/api/story/reading_time.rb', line 15 def time_in_seconds words_and_image_count_for_cards = cards.flat_map do |card| if card['story_elements'].present? card['story_elements'].map do |element| { 'words' => word_count_for_story_element(element), 'images' => image_count(element) } end end end.compact total_words_and_image_count = total_image_and_words_count(words_and_image_count_for_cards) total_readtime(total_words_and_image_count) end |