lib/read_time.rb in read_time-1.1.0 vs lib/read_time.rb in read_time-1.1.1
- old
+ new
@@ -2,10 +2,27 @@
module ReadTime
module String
@output = ""
+ def time_to_read
+ if seconds_to_read <= 1
+ puts "1 second"
+ elsif seconds_to_read > 1 && seconds_to_read < 60
+ puts "#{seconds_to_read} seconds"
+ else
+ if seconds_to_read >= 3600
+ hours_to_read(seconds_to_read)
+ else
+ minutes_to_read(seconds_to_read)
+ end
+ puts @output
+ end
+ end
+
+ protected
+
def seconds_to_read
(self.split(" ").count/3.3333333333).to_i
end
def minutes_to_read(secs)
@@ -36,23 +53,9 @@
if secs % 3600 > 0
minutes_to_read(secs % 3600)
end
end
- def time_to_read
- if seconds_to_read <= 1
- puts "1 second"
- elsif seconds_to_read > 1 && seconds_to_read < 60
- puts "#{seconds_to_read} seconds"
- else
- if seconds_to_read >= 3600
- hours_to_read(seconds_to_read)
- else
- minutes_to_read(seconds_to_read)
- end
- puts @output
- end
- end
end
end
class String
include ReadTime::String