to_cardinal 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +23 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +8 -0
- data/lib/to_cardinal.rb +69 -0
- data/lib/to_cardinal/version.rb +3 -0
- data/spec/lib/to_cardinal_spec.rb +38 -0
- data/spec/spec_helper.rb +4 -0
- data/to_cardinal.gemspec +25 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a409fff797b3bf3831c98f88117243c4ddf6d69f
|
4
|
+
data.tar.gz: e8899ed38425c12db26896b70c0ec491b8d86f09
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d1ba97dd38e12aeb605229487b62b8bc255edb69d855751ef20f60c31cc3e36220e509b56ea2ace720db2c8895be66d8af75436feb82c329e26a8e1a03635f7
|
7
|
+
data.tar.gz: 4c8a591b9bc177296174b79551128e00f10558f3e15c9295d1784991707267d113c043e86d0d69e63b7f35e7ce637d1fe7372ac2b63eb191ad6286b87f992fdc
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.rvmrc
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 edudepetris
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# ToCardinal
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/edudepetris/to_cardinal.svg?branch=master)](https://travis-ci.org/edudepetris/to_cardinal)
|
4
|
+
[![Coverage Status](https://img.shields.io/coveralls/edudepetris/to_cardinal.svg)](https://coveralls.io/r/edudepetris/to_cardinal)
|
5
|
+
|
6
|
+
|
7
|
+
Ruby gem which will allow to convert from ordinal numbers to cardinal numbers.
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'to_cardinal'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install to_cardinal
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'to_cardinal'
|
29
|
+
|
30
|
+
# some ordinal numbers to cardinals
|
31
|
+
'first'.to_cardinal # => 1
|
32
|
+
'1st'.to_cardinal # => 1
|
33
|
+
'fourth'.to_cardinal # => 4
|
34
|
+
'4th'.to_cardinal # => 4
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( https://github.com/[my-github-username]/to_cardinal/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/to_cardinal.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require "to_cardinal/version"
|
2
|
+
|
3
|
+
module ToCardinal
|
4
|
+
|
5
|
+
class ::String
|
6
|
+
def to_cardinal
|
7
|
+
case self.downcase
|
8
|
+
when 'first', '1st'
|
9
|
+
1
|
10
|
+
when 'second', '2nd'
|
11
|
+
2
|
12
|
+
when 'third', '3rd'
|
13
|
+
3
|
14
|
+
when 'fourth', '4th'
|
15
|
+
4
|
16
|
+
when 'fifth', '5th'
|
17
|
+
5
|
18
|
+
when 'sixth', '6th'
|
19
|
+
6
|
20
|
+
when 'seventh', '7th'
|
21
|
+
7
|
22
|
+
when 'eighth', '8th'
|
23
|
+
8
|
24
|
+
when 'ninth', '9th'
|
25
|
+
9
|
26
|
+
when 'tenth', '10th'
|
27
|
+
10
|
28
|
+
when 'eleventh', '11th'
|
29
|
+
11
|
30
|
+
when 'twelfth', '12th'
|
31
|
+
12
|
32
|
+
when 'thirteenth', '13th'
|
33
|
+
13
|
34
|
+
when 'fourteenth', '14th'
|
35
|
+
14
|
36
|
+
when 'fifteenth', '15th'
|
37
|
+
15
|
38
|
+
when 'sixteenth', '16th'
|
39
|
+
16
|
40
|
+
when 'seventeenth', '17th'
|
41
|
+
17
|
42
|
+
when 'eighteenth', '18th'
|
43
|
+
18
|
44
|
+
when 'nineteenth', '19th'
|
45
|
+
19
|
46
|
+
when 'twentieth', '20th'
|
47
|
+
20
|
48
|
+
when 'thirtieth', '30th'
|
49
|
+
30
|
50
|
+
when 'fortieth', '40th'
|
51
|
+
40
|
52
|
+
when 'fiftieth', '50th'
|
53
|
+
50
|
54
|
+
when 'sixtieth', '60th'
|
55
|
+
60
|
56
|
+
when 'seventieth', '70th'
|
57
|
+
70
|
58
|
+
when 'eightieth', '80th'
|
59
|
+
80
|
60
|
+
when 'ninetieth', '90th'
|
61
|
+
90
|
62
|
+
when 'hundredth', '100th'
|
63
|
+
100
|
64
|
+
else
|
65
|
+
-1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ToCardinal do
|
4
|
+
cardinals = [
|
5
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
|
6
|
+
19, 20, 30, 40, 50, 60, 70, 80, 90, 100]
|
7
|
+
|
8
|
+
full_ordinals = %w'
|
9
|
+
first second third fourth fifth sixth seventh eighth ninth
|
10
|
+
tenth eleventh twelfth thirteenth fourteenth fifteenth sixteenth
|
11
|
+
seventeenth eighteenth nineteenth twentieth thirtieth fortieth fiftieth
|
12
|
+
sixtieth seventieth eightieth ninetieth hundredth'
|
13
|
+
|
14
|
+
abbreviation_ordinal = %w'
|
15
|
+
1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th 13th 14th 15th
|
16
|
+
16th 17th 18th 19th 20th 30th 40th 50th 60th 70th 80th 90th 100th'
|
17
|
+
|
18
|
+
full_ordinals.each_with_index do |ordinal, index|
|
19
|
+
cardinal = cardinals[index]
|
20
|
+
|
21
|
+
it "converts full ordinal #{ordinal} to cardinal #{cardinal}" do
|
22
|
+
expect(ordinal.to_cardinal).to eq cardinal
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
abbreviation_ordinal.each_with_index do |ordinal, index|
|
27
|
+
cardinal = cardinals[index]
|
28
|
+
|
29
|
+
it "converts abbreviation ordinal #{ordinal} to cardinal #{cardinal}" do
|
30
|
+
expect(ordinal.to_cardinal).to eq cardinal
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'converts by default to -1' do
|
35
|
+
expect('anything'.to_cardinal).to eq -1
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/to_cardinal.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'to_cardinal/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "to_cardinal"
|
8
|
+
spec.version = ToCardinal::VERSION
|
9
|
+
spec.authors = ["edu depetris"]
|
10
|
+
spec.email = ["edu.depetris.00@gmail.com"]
|
11
|
+
spec.summary = %q{Conver ordinal numbers to cardinal numbers}
|
12
|
+
spec.description = %q{Convert full ordinal numbers like 'second' to cardinal numbers like 2}
|
13
|
+
spec.homepage = "https://github.com/edudepetris/to_cardinal"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
24
|
+
spec.add_development_dependency "coveralls", "~> 0.7"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: to_cardinal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- edu depetris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
description: Convert full ordinal numbers like 'second' to cardinal numbers like 2
|
70
|
+
email:
|
71
|
+
- edu.depetris.00@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".coveralls.yml"
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/to_cardinal.rb
|
84
|
+
- lib/to_cardinal/version.rb
|
85
|
+
- spec/lib/to_cardinal_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
- to_cardinal.gemspec
|
88
|
+
homepage: https://github.com/edudepetris/to_cardinal
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.5
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Conver ordinal numbers to cardinal numbers
|
112
|
+
test_files:
|
113
|
+
- spec/lib/to_cardinal_spec.rb
|
114
|
+
- spec/spec_helper.rb
|