weight 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +9 -0
- data/README.md +14 -2
- data/lib/weight.rb +8 -4
- data/lib/weight/configuration.rb +4 -0
- data/lib/weight/version.rb +1 -1
- data/spec/weight/configuration_spec.rb +1 -0
- data/spec/weight_spec.rb +2 -0
- metadata +93 -75
- checksums.yaml +0 -7
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,11 +1,23 @@
|
|
1
|
-
# Weight (0.0.
|
1
|
+
# Weight (0.0.2 alpha version)
|
2
2
|
|
3
|
-
[](https://codeclimate.com/github/shemerey/weight)
|
3
|
+
* [](https://codeclimate.com/github/shemerey/weight)
|
4
|
+
* [](https://travis-ci.org/shemerey/weight)
|
4
5
|
|
5
6
|
It's dead simple Value object, which provides convenient way to work with
|
6
7
|
weight in a different unit systems. It could be useful if you have to work with
|
7
8
|
different unit system, for example you have to work with :kg as well as :lb for USA
|
8
9
|
|
10
|
+
## Compatible with:
|
11
|
+
|
12
|
+
* mri 2.0.0
|
13
|
+
* mri 1.9.3
|
14
|
+
* mri 1.9.2
|
15
|
+
* jruby-19mode
|
16
|
+
* rbx-19mode
|
17
|
+
* jruby-18mode
|
18
|
+
* mri 1.8.7
|
19
|
+
* ree
|
20
|
+
|
9
21
|
## Installation
|
10
22
|
|
11
23
|
Add this line to your application's Gemfile:
|
data/lib/weight.rb
CHANGED
@@ -24,19 +24,19 @@ class Weight
|
|
24
24
|
# Returns the weight converted to pounds
|
25
25
|
# @return [Float] The weight in pounds
|
26
26
|
def to_kgs
|
27
|
-
|
27
|
+
round(raw_data_in_kg)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Returns the weight converted to kilograms
|
31
31
|
# @return [Float] The weight in kilograms
|
32
32
|
def to_lbs
|
33
|
-
(raw_data_in_kg * pounds_per_kilogram)
|
33
|
+
round(raw_data_in_kg * pounds_per_kilogram)
|
34
34
|
end
|
35
35
|
|
36
36
|
# Returns the weight converted to pounds
|
37
37
|
# @return [Float] The weight in pounds
|
38
38
|
def to_f
|
39
|
-
value.to_f
|
39
|
+
round(value.to_f)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Returns the weight in pounds rounded to the closest integer
|
@@ -61,7 +61,7 @@ class Weight
|
|
61
61
|
# @raise [TypeError] When the argument passed is not a Weight
|
62
62
|
def ==(other)
|
63
63
|
raise TypeError, 'You can only compare weights' unless other.is_a?(Weight)
|
64
|
-
|
64
|
+
self.to_kgs == other.to_kgs
|
65
65
|
end
|
66
66
|
|
67
67
|
# Comparison operator
|
@@ -102,6 +102,10 @@ class Weight
|
|
102
102
|
|
103
103
|
private
|
104
104
|
|
105
|
+
def round(value)
|
106
|
+
sprintf("%0.0#{round_level}f", value.to_f).to_f
|
107
|
+
end
|
108
|
+
|
105
109
|
# The weight expressed in kilograms for internal usage
|
106
110
|
# @return [Float] The weight in pounds
|
107
111
|
# @raise [TypeError] When the unit passed was neither kg nor lb
|
data/lib/weight/configuration.rb
CHANGED
data/lib/weight/version.rb
CHANGED
data/spec/weight_spec.rb
CHANGED
metadata
CHANGED
@@ -1,79 +1,91 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: weight
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Anton Shemerey
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2013-11-19 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
14
21
|
name: bundler
|
15
|
-
|
16
|
-
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
17
25
|
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
|
20
|
-
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 9
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 3
|
31
|
+
version: "1.3"
|
21
32
|
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.3'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
33
|
type: :development
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
35
46
|
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
47
|
type: :development
|
48
|
+
requirement: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
49
60
|
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
61
|
type: :development
|
62
|
+
requirement: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: pry
|
65
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
63
74
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
75
|
+
type: :development
|
76
|
+
requirement: *id004
|
69
77
|
description: Dead simple value object, with one purpose work with weight
|
70
|
-
email:
|
78
|
+
email:
|
71
79
|
- shemerey@gmail.com
|
72
80
|
executables: []
|
81
|
+
|
73
82
|
extensions: []
|
83
|
+
|
74
84
|
extra_rdoc_files: []
|
75
|
-
|
85
|
+
|
86
|
+
files:
|
76
87
|
- .gitignore
|
88
|
+
- .travis.yml
|
77
89
|
- Gemfile
|
78
90
|
- LICENSE.txt
|
79
91
|
- README.md
|
@@ -87,33 +99,39 @@ files:
|
|
87
99
|
- spec/weight_spec.rb
|
88
100
|
- weight.gemspec
|
89
101
|
homepage: https://github.com/shemerey/weight
|
90
|
-
licenses:
|
102
|
+
licenses:
|
91
103
|
- MIT
|
92
|
-
metadata: {}
|
93
104
|
post_install_message:
|
94
105
|
rdoc_options: []
|
95
|
-
|
106
|
+
|
107
|
+
require_paths:
|
96
108
|
- lib
|
97
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
version: "0"
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
107
127
|
requirements: []
|
128
|
+
|
108
129
|
rubyforge_project:
|
109
|
-
rubygems_version:
|
130
|
+
rubygems_version: 1.8.25
|
110
131
|
signing_key:
|
111
|
-
specification_version:
|
112
|
-
summary: It's dead simple Value object, which provides convenient way to work with
|
113
|
-
|
114
|
-
different unit system, for example you have to work with :kg as well as :lb for
|
115
|
-
USA
|
116
|
-
test_files:
|
132
|
+
specification_version: 3
|
133
|
+
summary: It's dead simple Value object, which provides convenient way to work with weight in a different unit systems. It could be useful if you have to work with different unit system, for example you have to work with :kg as well as :lb for USA
|
134
|
+
test_files:
|
117
135
|
- spec/spec_helper.rb
|
118
136
|
- spec/weight/configuration_spec.rb
|
119
137
|
- spec/weight_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: aa6ce855ed5b69b14e47239e204a95bd8f0aa8ee
|
4
|
-
data.tar.gz: 9ae53a6cf99f0cf5d474d49baecd3169e084379e
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 31bbe20390655459046b40bc53428ca9fa1c36447fa306abbe43909cd1b15f1289cdda20ffddfc5eb90dfd93fceb4ef4c90f583a28378f0958a686450a626b76
|
7
|
-
data.tar.gz: c172d0566ba2646a19096a2087316a46c277068adc606b187a845abe7d42cd8bc5d74c7f6665d893617838e58ca369e8118089063243120835b67e6e195954ac
|