-
- All Implemented Interfaces:
public final class ReadingTimeCalculates the reading time of the given text.
Based on Medium's calculation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classReadingTime.Companion
-
Field Summary
Fields Modifier and Type Field Description private Stringtextprivate Integerwpmprivate BooleanexcludeImagesprivate Integerextraprivate Stringpostfixprivate Stringpluralprivate RoundingModeroundingMode
-
Constructor Summary
Constructors Constructor Description ReadingTime(String text, Integer wpm, String postfix, String plural, Boolean excludeImages, Integer extra, RoundingMode roundingMode)Constructs a new ReadingTime object. ReadingTime(String text, Integer wpm, String postfix, String plural, Boolean excludeImages, Integer extra)Constructs a new ReadingTime object. ReadingTime(String text, Integer wpm, String postfix, String plural, Boolean excludeImages)Constructs a new ReadingTime object. ReadingTime(String text, Integer wpm, String postfix, String plural)Constructs a new ReadingTime object. ReadingTime(String text, Integer wpm, String postfix)Constructs a new ReadingTime object. ReadingTime(String text, Integer wpm)Constructs a new ReadingTime object. ReadingTime(String text)Constructs a new ReadingTime object.
-
Method Summary
Modifier and Type Method Description final StringgetText()final UnitsetText(String text)final IntegergetWpm()final UnitsetWpm(Integer wpm)final BooleangetExcludeImages()final UnitsetExcludeImages(Boolean excludeImages)final IntegergetExtra()final UnitsetExtra(Integer extra)final StringgetPostfix()final UnitsetPostfix(String postfix)final StringgetPlural()final UnitsetPlural(String plural)final RoundingModegetRoundingMode()final UnitsetRoundingMode(RoundingMode roundingMode)final DoublecalcReadingTimeInSec()Calculates and returns the reading time in seconds. final StringcalcReadingTime()Calculates and returns the reading time. -
-
Constructor Detail
-
ReadingTime
ReadingTime(String text, Integer wpm, String postfix, String plural, Boolean excludeImages, Integer extra, RoundingMode roundingMode)
Constructs a new ReadingTime object.- Parameters:
text- The text to be evaluated.wpm- The words per minute reading average.postfix- The value to be appended to the reading time.plural- The value to be appended if the reading time is more than 1 minute.excludeImages- Images are excluded from the reading time when set.extra- Additional seconds to be added to the total reading time.roundingMode- The RoundingMode to apply.
-
ReadingTime
ReadingTime(String text, Integer wpm, String postfix, String plural, Boolean excludeImages, Integer extra)
Constructs a new ReadingTime object.- Parameters:
text- The text to be evaluated.wpm- The words per minute reading average.postfix- The value to be appended to the reading time.plural- The value to be appended if the reading time is more than 1 minute.excludeImages- Images are excluded from the reading time when set.extra- Additional seconds to be added to the total reading time.
-
ReadingTime
ReadingTime(String text, Integer wpm, String postfix, String plural, Boolean excludeImages)
Constructs a new ReadingTime object.- Parameters:
text- The text to be evaluated.wpm- The words per minute reading average.postfix- The value to be appended to the reading time.plural- The value to be appended if the reading time is more than 1 minute.excludeImages- Images are excluded from the reading time when set.
-
ReadingTime
ReadingTime(String text, Integer wpm, String postfix, String plural)
Constructs a new ReadingTime object.- Parameters:
text- The text to be evaluated.wpm- The words per minute reading average.postfix- The value to be appended to the reading time.plural- The value to be appended if the reading time is more than 1 minute.
-
ReadingTime
ReadingTime(String text, Integer wpm, String postfix)
Constructs a new ReadingTime object.- Parameters:
text- The text to be evaluated.wpm- The words per minute reading average.postfix- The value to be appended to the reading time.
-
ReadingTime
ReadingTime(String text, Integer wpm)
Constructs a new ReadingTime object.- Parameters:
text- The text to be evaluated.wpm- The words per minute reading average.
-
ReadingTime
ReadingTime(String text)
Constructs a new ReadingTime object.- Parameters:
text- The text to be evaluated.
-
-
Method Detail
-
getExcludeImages
final Boolean getExcludeImages()
-
setExcludeImages
final Unit setExcludeImages(Boolean excludeImages)
-
getPostfix
final String getPostfix()
-
setPostfix
final Unit setPostfix(String postfix)
- Parameters:
postfix- The value to be appended to the reading time.
-
setPlural
final Unit setPlural(String plural)
- Parameters:
plural- The value to be appended if the reading time is more than 1 minute.
-
getRoundingMode
final RoundingMode getRoundingMode()
-
setRoundingMode
final Unit setRoundingMode(RoundingMode roundingMode)
- Parameters:
roundingMode- The RoundingMode to apply.
-
calcReadingTimeInSec
final Double calcReadingTimeInSec()
Calculates and returns the reading time in seconds.
((word count / wpm) * 60) + images + extra
-
calcReadingTime
final String calcReadingTime()
Calculates and returns the reading time. (eg. 1 min read)
(reading time in sec / 60) + postfix
-
-
-
-