Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Rees authored and Gareth Rees committed Sep 20, 2011
0 parents commit 2a1ced6
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in readingtime.gemspec
gemspec
1 change: 1 addition & 0 deletions Rakefile
@@ -0,0 +1 @@
require 'bundler/gem_tasks'
6 changes: 6 additions & 0 deletions lib/readingtime.rb
@@ -0,0 +1,6 @@
require "readingtime/version"
require "readingtime/core_ext"

module Readingtime
# Your code goes here...
end
11 changes: 11 additions & 0 deletions lib/readingtime/core_ext.rb
@@ -0,0 +1,11 @@
String.class_eval do
def reading_time
word = self.scan(/(\w|-)+/).size

minutes = (word / 200).floor
seconds = (word % 200 / (200 / 60)).floor

return minutes.to_s + ":" + seconds.to_s

end
end
3 changes: 3 additions & 0 deletions lib/readingtime/version.rb
@@ -0,0 +1,3 @@
module Readingtime
VERSION = "0.0.1"
end
20 changes: 20 additions & 0 deletions readingtime.gemspec
@@ -0,0 +1,20 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "readingtime/version"

Gem::Specification.new do |s|
s.name = "readingtime"
s.version = Readingtime::VERSION
s.authors = ["Gareth Rees"]
s.email = ["reesG12@cardiff.ac.uk"]
s.homepage = ""
s.summary = %q{TODO: Write a gem summary}
s.description = %q{TODO: Write a gem description}

s.rubyforge_project = "readingtime"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
end

0 comments on commit 2a1ced6

Please sign in to comment.