Class: Sevgi::Sundries::Ruler
- Defined in:
- lib/sevgi/sundries/ruler.rb
Overview
<------------------------ d = n x sd -----------------------------><--- waste = 2 x margin ---> <----- u = unit x multiple -----> <------ sd = su x sn -----> (computed margin >= given margin)
|----------+----------+----------|----------+----------+----------|···························|
<----------------------------------------- brut ---------------------------------------------->
Direct Known Subclasses
Instance Attribute Summary collapse
-
#brut ⇒ Object
readonly
Returns the value of attribute brut.
-
#sub ⇒ Object
readonly
Returns the value of attribute sub.
Attributes inherited from Interval
Instance Method Summary collapse
- #expand ⇒ Object
-
#initialize(brut:, unit:, multiple:, margin: 0.0) ⇒ Ruler
constructor
A new instance of Ruler.
- #margin ⇒ Object
- #ms ⇒ Object
- #sd ⇒ Object
- #sn ⇒ Object
- #su ⇒ Object
- #waste ⇒ Object
Methods inherited from Interval
[], #[], #count, #d, #ds, #h, #hs, #nds, #nhs
Constructor Details
#initialize(brut:, unit:, multiple:, margin: 0.0) ⇒ Ruler
Returns a new instance of Ruler.
62 63 64 |
# File 'lib/sevgi/sundries/ruler.rb', line 62 def initialize(brut:, unit:, multiple:, margin: 0.0) super(@sub = Interval.new(unit, multiple), divide(unit:, multiple:, brut: (@brut = brut.to_f), margin:)) end |
Instance Attribute Details
#brut ⇒ Object (readonly)
Returns the value of attribute brut.
60 61 62 |
# File 'lib/sevgi/sundries/ruler.rb', line 60 def brut @brut end |
#sub ⇒ Object (readonly)
Returns the value of attribute sub.
60 61 62 |
# File 'lib/sevgi/sundries/ruler.rb', line 60 def sub @sub end |
Instance Method Details
#expand ⇒ Object
66 |
# File 'lib/sevgi/sundries/ruler.rb', line 66 def = self.class.new(unit: sub.u, multiple: 1, brut: d + waste, margin:) |
#margin ⇒ Object
68 |
# File 'lib/sevgi/sundries/ruler.rb', line 68 def margin = @margin ||= waste / 2.0 |
#ms ⇒ Object
70 |
# File 'lib/sevgi/sundries/ruler.rb', line 70 def ms = @ms ||= .ds |
#sd ⇒ Object
76 |
# File 'lib/sevgi/sundries/ruler.rb', line 76 def sd = @sub.d |
#sn ⇒ Object
74 |
# File 'lib/sevgi/sundries/ruler.rb', line 74 def sn = @sub.n |
#su ⇒ Object
78 |
# File 'lib/sevgi/sundries/ruler.rb', line 78 def su = @sub.u |
#waste ⇒ Object
72 |
# File 'lib/sevgi/sundries/ruler.rb', line 72 def waste = @waste ||= brut - d |