rdoc-generator-solarfish 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rubocop.yml +26 -0
  4. data/.travis.yml +9 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE +21 -0
  7. data/README.md +175 -0
  8. data/Rakefile +28 -0
  9. data/data/rdoc-generator-solarfish/templates/onepage.slim +110 -0
  10. data/data/rdoc-generator-solarfish/themes/common/fonts/LICENSE +7 -0
  11. data/data/rdoc-generator-solarfish/themes/common/fonts/LICENSE.Raleway +95 -0
  12. data/data/rdoc-generator-solarfish/themes/common/fonts/LICENSE.Roboto +201 -0
  13. data/data/rdoc-generator-solarfish/themes/common/fonts/Raleway-Regular.ttf +0 -0
  14. data/data/rdoc-generator-solarfish/themes/common/fonts/Raleway-SemiBold.ttf +0 -0
  15. data/data/rdoc-generator-solarfish/themes/common/fonts/Roboto-Regular.ttf +0 -0
  16. data/data/rdoc-generator-solarfish/themes/common/syntax/LICENSE +3 -0
  17. data/data/rdoc-generator-solarfish/themes/common/syntax/LICENSE.onelight +20 -0
  18. data/data/rdoc-generator-solarfish/themes/common/syntax/onelight.sass +47 -0
  19. data/data/rdoc-generator-solarfish/themes/light/main.sass +215 -0
  20. data/data/rdoc-generator-solarfish/themes/light.yml +16 -0
  21. data/docs/example.rb +142 -0
  22. data/docs/example_output/Raleway-Regular.ttf +0 -0
  23. data/docs/example_output/Raleway-SemiBold.ttf +0 -0
  24. data/docs/example_output/Roboto-Regular.ttf +0 -0
  25. data/docs/example_output/created.rid +2 -0
  26. data/docs/example_output/index.html +404 -0
  27. data/docs/example_output/index.json +428 -0
  28. data/docs/example_output/main.css +210 -0
  29. data/docs/example_output/onelight.css +22 -0
  30. data/lib/rdoc/discover.rb +1 -0
  31. data/lib/rdoc/generator/doc_loader.rb +315 -0
  32. data/lib/rdoc/generator/html_writer.rb +35 -0
  33. data/lib/rdoc/generator/json_writer.rb +16 -0
  34. data/lib/rdoc/generator/settings.rb +57 -0
  35. data/lib/rdoc/generator/solarfish.rb +135 -0
  36. data/lib/rdoc/generator/template_loader.rb +42 -0
  37. data/lib/rdoc/generator/theme_loader.rb +160 -0
  38. data/lib/solarfish.rb +2 -0
  39. data/rdoc-generator-solarfish.gemspec +31 -0
  40. data/test/test_generator.rb +95 -0
  41. data/test/test_theme_loader.rb +89 -0
  42. data/test/themes.rb +213 -0
  43. metadata +216 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ one-light-syntax:
2
+ Homepage: https://github.com/atom/one-light-syntax
3
+ License: LICENSE.onelight
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 GitHub Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ $bg: hsl(230, 1%, 98%)
2
+
3
+ $hue-0: hsl(230, 99%, 37%)
4
+
5
+ $hue-1: hsl(198, 99%, 37%)
6
+ $hue-2: hsl(221, 87%, 60%)
7
+ $hue-3: hsl(301, 63%, 40%)
8
+ $hue-4: hsl(119, 34%, 47%)
9
+
10
+ $hue-5: hsl( 5, 74%, 59%)
11
+ $hue-5-2: hsl(344, 84%, 43%)
12
+
13
+ $hue-6: hsl(41, 99%, 30%)
14
+ $hue-6-2: hsl(41, 99%, 38%)
15
+
16
+ .memberCode
17
+ background: $bg
18
+
19
+ .ruby-constant
20
+ color: $hue-6
21
+
22
+ .ruby-keyword
23
+ color: $hue-3
24
+
25
+ .ruby-ivar
26
+ color: $hue-5
27
+
28
+ .ruby-operator
29
+ color: $hue-2
30
+
31
+ .ruby-identifier
32
+ color: $hue-6
33
+
34
+ .ruby-node
35
+ color: $hue-6-2
36
+
37
+ .ruby-comment
38
+ color: $hue-0
39
+
40
+ .ruby-regexp
41
+ color: $hue-1
42
+
43
+ .ruby-value
44
+ color: $hue-5-2
45
+
46
+ .ruby-string
47
+ color: $hue-4
@@ -0,0 +1,215 @@
1
+ @mixin label($bgColor, $textColor)
2
+ background-color: $bgColor
3
+ color: $textColor
4
+ font-size: 12px
5
+ padding: 3px 5px
6
+ border-radius: 8px
7
+
8
+ body
9
+ margin: 0 10px 10px 2px
10
+ font-family: RobotoRegular
11
+ font-size: 16px
12
+
13
+ header
14
+ font-family: RalewaySemiBold
15
+
16
+ a
17
+ color: black
18
+ text-decoration: none
19
+
20
+ summary
21
+ outline: none
22
+ display: inline-block
23
+
24
+ &::-webkit-details-marker
25
+ display: none
26
+
27
+ .label
28
+ display: inline-block
29
+ margin: 0 2px 0 2px
30
+
31
+ &Module
32
+ @include label(#dff0d8, #3c763d)
33
+
34
+ &Class
35
+ @include label(#dff0d8, #3c763d)
36
+
37
+ &Included
38
+ @include label(#dff0d8, #3c763d)
39
+
40
+ &Extended
41
+ @include label(#dff0d8, #3c763d)
42
+
43
+ &Constant
44
+ @include label(#dff0d8, #3c763d)
45
+
46
+ &ClassMethod
47
+ @include label(#dff0d8, #3c763d)
48
+
49
+ &InstanceMethod
50
+ @include label(#d9edf7, #31708f)
51
+
52
+ &ClassAttribute
53
+ @include label(#d9edf7, #31708f)
54
+
55
+ &InstanceAttribute
56
+ @include label(#dff0d8, #3c763d)
57
+
58
+ &Public
59
+ @include label(#fcf8e3, #8a6d3b)
60
+
61
+ &Private
62
+ @include label(#fcf8e3, #8a6d3b)
63
+
64
+ &Protected
65
+ @include label(#fcf8e3, #8a6d3b)
66
+
67
+ .mainHeader
68
+ font-size: 32px
69
+ font-weight: 600
70
+ padding: 10px 0
71
+ margin: 10px 0 10px 350px
72
+
73
+ aside
74
+ float: left
75
+ width: 325px
76
+ overflow: hidden
77
+ position: fixed
78
+ overflow-y: scroll
79
+ bottom: 0
80
+ top: 0
81
+ padding-top: 10px
82
+ padding-right: 8px
83
+
84
+ a
85
+ display: inline-block
86
+
87
+ .tocClassBlock
88
+ border: 1px solid rgba(136,136,136,0.12)
89
+ background-color: #fafafa
90
+ border-radius: 3px
91
+ margin: 7px
92
+ width: 300px
93
+ position: relative
94
+ padding: 0px 2px 0px 2px
95
+
96
+ &:first-child
97
+ margin-top: 0
98
+
99
+ summary
100
+ display: flex
101
+ align-items: center
102
+ justify-content: center
103
+
104
+ &:after
105
+ content: "+"
106
+ color: #000
107
+ font-size: 20px
108
+ text-align: center
109
+ width: 20px
110
+ position: absolute
111
+ width: 40px
112
+ top: 9%
113
+ right: 0px
114
+
115
+ &[open] summary:after
116
+ content: "−"
117
+
118
+ .tocClass
119
+ flex-grow: 1
120
+ width: 190px
121
+ word-wrap: break-word
122
+ padding: 5px 3px 5px 3px
123
+
124
+ .tocGroupBlock
125
+ background-color: white
126
+
127
+ .tocGroup
128
+ display: block
129
+ padding: 5px 20px
130
+ border-bottom: 1px solid #f2f2f2
131
+ border-left: 3px solid transparent
132
+
133
+ &:hover
134
+ border-left: 3px solid #d0e7f2
135
+
136
+ &:last-child
137
+ border-bottom: none
138
+
139
+ main
140
+ margin-left: 340px
141
+
142
+ .classBlock
143
+ border: 1px solid #d9d9d9
144
+ border-radius: 5px
145
+ margin-top: 15px
146
+
147
+ .classHeader
148
+ display: flex
149
+ align-items: center
150
+ justify-content: center
151
+ background: #f3f3f3
152
+ color: black
153
+ padding: 5px
154
+ font-size: 22px
155
+
156
+ .className
157
+ flex-grow: 1
158
+ padding-left: 4px
159
+
160
+ .classComment
161
+ padding: 5px 5px 0 13px
162
+
163
+ .groupBlock
164
+ border-top: 1px solid #d9d9d9
165
+ padding: 5px 5px 0 5px
166
+ border-radius: 5px
167
+
168
+ .groupHeader
169
+ background: none
170
+ color: black
171
+ padding: 7px
172
+ font-size: 18px
173
+
174
+ .memberBlock
175
+ padding-bottom: 15px
176
+ border-bottom: 1px solid #d9d9d9
177
+ margin: 10px 30px 0 30px
178
+
179
+ &:last-child
180
+ border-bottom: none
181
+
182
+ .memberHeader
183
+ display: flex
184
+ align-items: center
185
+ justify-content: center
186
+
187
+ .memberName
188
+ flex-grow: 1
189
+ font-weight: bolder
190
+ padding-left: 4px
191
+
192
+ .memberSignature
193
+ font-size: 15px
194
+
195
+ .memberComment
196
+ font-size: 16px
197
+
198
+ .memberCode
199
+ border: 1px solid #d9d9d9
200
+ border-radius: 6px
201
+
202
+ summary:before
203
+ display: inline-block
204
+ vertical-align: middle
205
+ padding: 0 8px 0 8px
206
+ content: "+"
207
+ font-size: 20px
208
+ color: #000
209
+
210
+ &[open] summary:before
211
+ content: "−"
212
+
213
+ pre
214
+ padding: 0 8px 0 8px
215
+ font-size: 14px
@@ -0,0 +1,16 @@
1
+ head:
2
+ styles:
3
+ -
4
+ file: common/syntax/onelight.sass
5
+ -
6
+ file: light/main.sass
7
+ fonts:
8
+ -
9
+ file: common/fonts/Roboto-Regular.ttf
10
+ family: RobotoRegular
11
+ -
12
+ file: common/fonts/Raleway-Regular.ttf
13
+ family: RalewayRegular
14
+ -
15
+ file: common/fonts/Raleway-SemiBold.ttf
16
+ family: RalewaySemiBold
data/docs/example.rb ADDED
@@ -0,0 +1,142 @@
1
+ ##
2
+ # === RDoc::Generator::SolarFish example.
3
+ #
4
+ # This example employs variois RDoc features to demonstrate
5
+ # generator output.
6
+ #
7
+ # ---
8
+ #
9
+ # Links:
10
+ #
11
+ # 1. {Project Home Page}[https://github.com/rbdoc/rdoc-generator-solarfish)
12
+ # 2. {RDoc Documentation}[http://ruby-doc.org/stdlib-2.0.0/libdoc/rdoc/rdoc/RDoc/Markup.html]
13
+ #
14
+
15
+ ##
16
+ # A mixin for waterfowl creatures.
17
+ module Waterfowl
18
+ # Swimming helper.
19
+ def swim
20
+ puts 'swimming around'
21
+ end
22
+ end
23
+
24
+ ##
25
+ # The base class for all birds.
26
+ class Bird
27
+ ##
28
+ # Produce some noise.
29
+ #--
30
+ # FIXME: maybe extract this to a base class +Animal+?
31
+ #++
32
+ def speak # :yields: text
33
+ puts 'generic tweeting'
34
+ yield 'tweet'
35
+ yield 'tweet'
36
+ end
37
+
38
+ # Fly somewhere.
39
+ #
40
+ # Flying is the most critical feature of birds.
41
+ #
42
+ # :args: direction, velocity
43
+ #
44
+ # :call-seq:
45
+ # Bird.fly(symbol, number) -> bool
46
+ # Bird.fly(string, number) -> bool
47
+ #
48
+ # = Example
49
+ #
50
+ # fly(:south, 70)
51
+ def fly(direction, velocity)
52
+ _fly_impl(direction, velocity)
53
+ end
54
+
55
+ def _fly_impl(_direction, _velocity) # :nodoc:
56
+ puts "flying away: direction=#{direction}, velocity=#{velocity}"
57
+ end
58
+ end
59
+
60
+ ##
61
+ # A duck is a Waterfowl Bird.
62
+ #
63
+ # Features:
64
+ #
65
+ # bird::
66
+ #
67
+ # * speak
68
+ # * fly
69
+ #
70
+ # waterfowl::
71
+ #
72
+ # * swim
73
+ class Duck
74
+ extend Animal
75
+ include Waterfowl
76
+
77
+ # :section: Bird overrides
78
+
79
+ # Duck overrides generic implementation.
80
+ def speak
81
+ speech = quack
82
+ yield speech
83
+ end
84
+
85
+ # Implements quacking
86
+ def quack
87
+ 'quack'
88
+ end
89
+
90
+ private :quack
91
+
92
+ # :section: Duck extensions
93
+
94
+ # True for domestic ducks.
95
+ attr_accessor :domestic
96
+
97
+ # True for rubber ducks.
98
+ attr_reader :rubber
99
+
100
+ MAX_VELOCITY = 130 # Maximum velocity for a flying duck.
101
+
102
+ ##
103
+ # Global list of all rubber ducks.
104
+ #
105
+ # Use when in trouble.
106
+ @@rubber_ducks = []
107
+
108
+ # Returns list of all rubber ducks.
109
+ def self.rubber_ducks
110
+ @@rubber_ducks
111
+ end
112
+
113
+ # Creates a new duck.
114
+ def initialize(domestic, rubber)
115
+ @domestic = domestic
116
+ @rubber = rubber
117
+ @@rubber_ducks << self if rubber
118
+ end
119
+
120
+ # Checks if this duck is a useful one.
121
+ #
122
+ # :call-seq:
123
+ # Bird.useful? -> bool
124
+ def useful?
125
+ @domestic || @rubber
126
+ end
127
+ end
128
+
129
+ # Default velocity for a flying duck.
130
+ DEFAULT_DUCK_VELOCITY = 70
131
+
132
+ # Default rubber duck.
133
+ #
134
+ # *Note:*
135
+ # Global variables are evil, but rubber ducks are worth it.
136
+ $default_rubber_duck = Duck.new(false, true)
137
+
138
+ # Domestic rubber duck.
139
+ #
140
+ # *Note:*
141
+ # This is weird... Thus not making it global.
142
+ domestic_rubber_duck = Duck.new(true, true)
@@ -0,0 +1,2 @@
1
+ Fri, 07 Jun 2019 16:14:23 +0300
2
+ ./example.rb Fri, 07 Jun 2019 16:03:00 +0300