Class: Sevgi::Geometry::Interval
- Inherits:
-
Object
- Object
- Sevgi::Geometry::Interval
- Defined in:
- lib/sevgi/geometry/sundries/ruler.rb
Overview
<———————————– d = n x u ———————————>
<————–h = d / 2 —————>
|———---------———+———|———---------———+———|
<--- u --->
Direct Known Subclasses
Instance Attribute Summary collapse
-
#n ⇒ Object
readonly
Returns the value of attribute n.
-
#u ⇒ Object
readonly
Returns the value of attribute u.
Class Method Summary collapse
Instance Method Summary collapse
- #[](i) ⇒ Object
- #count(length) ⇒ Object
- #d ⇒ Object (also: #length)
- #ds ⇒ Object
- #h ⇒ Object
- #hs ⇒ Object
-
#initialize(e, n) ⇒ Interval
constructor
A new instance of Interval.
- #nds ⇒ Object
- #nhs ⇒ Object
Constructor Details
#initialize(e, n) ⇒ Interval
17 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 17 def initialize(e, n) = (@u, @n = measure(e), n) |
Instance Attribute Details
#n ⇒ Object (readonly)
Returns the value of attribute n.
15 16 17 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 15 def n @n end |
#u ⇒ Object (readonly)
Returns the value of attribute u.
15 16 17 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 15 def u @u end |
Class Method Details
.[](e, n) ⇒ Object
48 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 48 def [](e, n) = new(e, n) |
Instance Method Details
#[](i) ⇒ Object
19 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 19 def [](i) = ds[i] |
#count(length) ⇒ Object
21 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 21 def count(length) = (d / length.to_f).to_i |
#d ⇒ Object Also known as: length
23 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 23 def d = @d ||= n * u |
#ds ⇒ Object
25 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 25 def ds = @ds ||= Array.new(n + 1) { |i| i * u } |
#h ⇒ Object
27 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 27 def h = @h ||= d / 2.0 |
#hs ⇒ Object
29 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 29 def hs = @hs ||= Array.new(n) { |i| u * (0.5 + i) } |
#nds ⇒ Object
31 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 31 def nds = @nds ||= ds.size - 1 |
#nhs ⇒ Object
33 |
# File 'lib/sevgi/geometry/sundries/ruler.rb', line 33 def nhs = @nhs ||= hs.size - 1 |