fasteners 0 → 0.1
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.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/fasteners.gemspec +3 -1
- data/lib/fasteners.rb +7 -0
- data/lib/fasteners/bolt.rb +28 -0
- data/lib/fasteners/metric/nut.rb +100 -0
- data/lib/fasteners/nut.rb +28 -0
- data/lib/fasteners/socket_head_cap_screw.rb +23 -0
- data/lib/fasteners/washer.rb +24 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c857bea2cb4ce3c6f21403474044d4bbf108fcc7
|
4
|
+
data.tar.gz: 63c0b294701b3665c84d35bc4474938f8443d493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fb53822e5198c65e3630a79768bb567682392869ef997bf8c217e02e2d06c23aff086d1d21ae1ec466ac51b7a6f09873c3be1a5076eda7797795247b784d8fc
|
7
|
+
data.tar.gz: 5390896562cc01222d602912412a8187afee614e3a3faadf0c9c7fc429d48dc5c2137ceb3a52471714e8de2814157f1fdae1edefd248c2ffc025687e6c177af0
|
data/Gemfile
CHANGED
data/fasteners.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fasteners"
|
7
|
-
spec.version = '0'
|
7
|
+
spec.version = '0.1'
|
8
8
|
spec.authors = ["Brandon Fosdick"]
|
9
9
|
spec.email = ["bfoz@bfoz.net"]
|
10
10
|
spec.summary = %q{Nuts and bolts}
|
@@ -17,6 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_dependency 'units', '~> 2.3'
|
21
|
+
|
20
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
21
23
|
spec.add_development_dependency "rake"
|
22
24
|
end
|
data/lib/fasteners.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fasteners
|
2
|
+
# A generic Bolt
|
3
|
+
class Bolt
|
4
|
+
# @!attribute clearance_diameter
|
5
|
+
# @return [Number] the diameter of the clearance hole that fits the bolt
|
6
|
+
attr_reader :clearance_diameter
|
7
|
+
|
8
|
+
# @!attribute diameter
|
9
|
+
# @return [Number] the diameter of the bolt shaft
|
10
|
+
attr_reader :diameter
|
11
|
+
|
12
|
+
# @!attribute head_diameter
|
13
|
+
# @return [Number] the diameter of the bolt head
|
14
|
+
attr_reader :head_diameter
|
15
|
+
|
16
|
+
# @!attribute head_length
|
17
|
+
# @return [Number] the length of the bolt head
|
18
|
+
attr_reader :head_length
|
19
|
+
|
20
|
+
# @!attribute length
|
21
|
+
# @return [Number] the length of the bolt shaft
|
22
|
+
attr_reader :length
|
23
|
+
|
24
|
+
def initialize(**options)
|
25
|
+
options.each {|k,v| respond_to?(k) && instance_variable_set("@#{k}", v) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'units'
|
2
|
+
|
3
|
+
module Fasteners
|
4
|
+
module Metric
|
5
|
+
# http://en.wikipedia.org/wiki/Nut_(hardware)
|
6
|
+
class Nut < Fasteners::Nut
|
7
|
+
THICKNESS = {
|
8
|
+
2 => 1.6,
|
9
|
+
2.5 => 2,
|
10
|
+
3 => 2.4,
|
11
|
+
4 => 3.2,
|
12
|
+
5 => 4,
|
13
|
+
6 => 5,
|
14
|
+
7 => 5.5,
|
15
|
+
8 => 6.5,
|
16
|
+
10 => 8,
|
17
|
+
12 => 10,
|
18
|
+
14 => 11,
|
19
|
+
16 => 13,
|
20
|
+
18 => 15,
|
21
|
+
20 => 16,
|
22
|
+
24 => 19,
|
23
|
+
30 => 24,
|
24
|
+
36 => 29,
|
25
|
+
}
|
26
|
+
|
27
|
+
THIN_THICKNESS = {
|
28
|
+
2 => 1.2,
|
29
|
+
2.5 => 1.6,
|
30
|
+
3 => 1.8,
|
31
|
+
4 => 2.2,
|
32
|
+
5 => 2.7,
|
33
|
+
6 => 3.2,
|
34
|
+
7 => 3.5,
|
35
|
+
8 => 4,
|
36
|
+
10 => 5,
|
37
|
+
12 => 6,
|
38
|
+
14 => 7,
|
39
|
+
16 => 8,
|
40
|
+
18 => 9,
|
41
|
+
20 => 10,
|
42
|
+
}
|
43
|
+
|
44
|
+
WIDTH = {
|
45
|
+
1 => 2.5,
|
46
|
+
1.6 => 3.2,
|
47
|
+
2 => 4,
|
48
|
+
2.5 => 5,
|
49
|
+
3 => 5.5,
|
50
|
+
3.5 => 6,
|
51
|
+
4 => 7,
|
52
|
+
5 => 8,
|
53
|
+
6 => 10,
|
54
|
+
7 => 11,
|
55
|
+
8 => 13,
|
56
|
+
10 => 16,
|
57
|
+
12 => 18,
|
58
|
+
14 => 21,
|
59
|
+
16 => 24,
|
60
|
+
18 => 27,
|
61
|
+
20 => 30,
|
62
|
+
22 => 32,
|
63
|
+
24 => 36,
|
64
|
+
27 => 41,
|
65
|
+
30 => 46,
|
66
|
+
36 => 55,
|
67
|
+
}
|
68
|
+
|
69
|
+
# @param diameter [Number] the nominal diameter of the hole
|
70
|
+
# @param type [Symbol] the type of the {Nut}
|
71
|
+
# @return [Number] the thickness of the {Nut} corresponding to the given diameter
|
72
|
+
def self.thickness(diameter, type)
|
73
|
+
# Remove any units that diameter might have (the Hash doesn't like them)
|
74
|
+
diameter = diameter.value if diameter.respond_to?(:value)
|
75
|
+
|
76
|
+
case type
|
77
|
+
when :thin then THIN_THICKNESS[diameter] || raise(ArgumentError, "There is no thin version of an M#{diameter} nut")
|
78
|
+
else
|
79
|
+
THICKNESS[diameter] || raise(ArgumentError, "There is no standard thickness for an M#{diameter} nut")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# @param diameter [Number] the nominal diameter of the hole
|
84
|
+
# @return [Number] the width of the {Nut} between the flats
|
85
|
+
def self.width(diameter)
|
86
|
+
# Remove any units that diameter might have (the Hash doesn't like them)
|
87
|
+
diameter = diameter.value if diameter.respond_to?(:value)
|
88
|
+
|
89
|
+
WIDTH[diameter] || raise(ArgumentError, "There is no standard width for an M#{diameter} nut")
|
90
|
+
end
|
91
|
+
|
92
|
+
def initialize(**options)
|
93
|
+
super **options
|
94
|
+
|
95
|
+
@height = self.class.thickness(hole_diameter, type).mm
|
96
|
+
@width = self.class.width(hole_diameter).mm
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fasteners
|
2
|
+
# A generic Nut
|
3
|
+
# http://en.wikipedia.org/wiki/Nut_(hardware)
|
4
|
+
class Nut
|
5
|
+
# @!attribute height
|
6
|
+
# @return [Number] the height of the {Nut}
|
7
|
+
attr_reader :height
|
8
|
+
alias :thickness :height
|
9
|
+
|
10
|
+
# @!attribute hole_diameter
|
11
|
+
# @return [Number] the nominal diameter of the screw that the {Nut} fits
|
12
|
+
attr_reader :hole_diameter
|
13
|
+
alias :diameter :hole_diameter
|
14
|
+
|
15
|
+
# @!attribute width
|
16
|
+
# @return [Number] the width of the {Nut} between the flats (also the wrench size)
|
17
|
+
attr_reader :width
|
18
|
+
alias :indiameter :width
|
19
|
+
|
20
|
+
# @!attribute type
|
21
|
+
# @return [Symbol] :hex, :thin, :jam, :nylon (defaults to :hex)
|
22
|
+
attr_reader :type
|
23
|
+
|
24
|
+
def initialize(**options)
|
25
|
+
options.each {|k,v| respond_to?(k) && instance_variable_set("@#{k}", v) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'bolt'
|
2
|
+
|
3
|
+
module Fasteners
|
4
|
+
# Your standard metric socket head cap screw
|
5
|
+
# http://en.wikipedia.org/wiki/ISO_metric_screw_thread
|
6
|
+
class SocketHeadCapScrew < Bolt
|
7
|
+
# @!attribute socket_diameter
|
8
|
+
# @return [Number] the diameter of the socket (the indiameter for hexagonal sockets)
|
9
|
+
attr_reader :socket_diameter
|
10
|
+
|
11
|
+
# @param diameter [Number] The nominal diameter of the screw
|
12
|
+
def initialize(diameter, **options)
|
13
|
+
options[:diameter] = diameter
|
14
|
+
options[:head_diameter] = 2 * diameter
|
15
|
+
options[:head_length] = diameter
|
16
|
+
|
17
|
+
@socket_depth = 0.75 * diameter
|
18
|
+
@socket_diameter = 0.8 * diameter
|
19
|
+
|
20
|
+
super **options
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fasteners
|
2
|
+
# A generic Washer
|
3
|
+
# http://en.wikipedia.org/wiki/Washer_(hardware)
|
4
|
+
class Washer
|
5
|
+
# @!attribute thickness
|
6
|
+
# @return [Number] the thickness of the {Washer}
|
7
|
+
attr_reader :thickness
|
8
|
+
alias :height :thickness
|
9
|
+
|
10
|
+
# @!attribute inner_diameter
|
11
|
+
# @return [Number] the diameter of the hole
|
12
|
+
attr_reader :inner_diameter
|
13
|
+
alias :hole_diameter :inner_diameter
|
14
|
+
alias :diameter :hole_diameter
|
15
|
+
|
16
|
+
# @!attribute outer_diameter
|
17
|
+
# @return [Number] the outer diameter of the {Washer}
|
18
|
+
attr_reader :outer_diameter
|
19
|
+
|
20
|
+
def initialize(**options)
|
21
|
+
options.each {|k,v| respond_to?(k) && instance_variable_set("@#{k}", v) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fasteners
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0'
|
4
|
+
version: '0.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Fosdick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: units
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,6 +64,11 @@ files:
|
|
50
64
|
- Rakefile
|
51
65
|
- fasteners.gemspec
|
52
66
|
- lib/fasteners.rb
|
67
|
+
- lib/fasteners/bolt.rb
|
68
|
+
- lib/fasteners/metric/nut.rb
|
69
|
+
- lib/fasteners/nut.rb
|
70
|
+
- lib/fasteners/socket_head_cap_screw.rb
|
71
|
+
- lib/fasteners/washer.rb
|
53
72
|
homepage: http://github.com/bfoz/fasteners-ruby
|
54
73
|
licenses:
|
55
74
|
- BSD
|