Class: Diagrams::Spring
Instance Attribute Summary collapse
-
#imposed ⇒ Object
Returns the value of attribute imposed.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#pref ⇒ Object
Returns the value of attribute pref.
-
#shrink ⇒ Object
Returns the value of attribute shrink.
-
#stretch ⇒ Object
Returns the value of attribute stretch.
-
#weight ⇒ Object
not used yet.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(min, shrink, pref, stretch, max) ⇒ Spring
constructor
A new instance of Spring.
- #inspect ⇒ Object
Constructor Details
#initialize(min, shrink, pref, stretch, max) ⇒ Spring
Returns a new instance of Spring.
13 14 15 16 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 13 def initialize(min,shrink,pref,stretch,max) @min,@shrink,@pref,@stretch,@max = min, shrink, pref, stretch, max end |
Instance Attribute Details
#imposed ⇒ Object
Returns the value of attribute imposed.
11 12 13 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 11 def imposed @imposed end |
#max ⇒ Object
Returns the value of attribute max.
9 10 11 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 9 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
9 10 11 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 9 def min @min end |
#pref ⇒ Object
Returns the value of attribute pref.
9 10 11 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 9 def pref @pref end |
#shrink ⇒ Object
Returns the value of attribute shrink.
9 10 11 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 9 def shrink @shrink end |
#stretch ⇒ Object
Returns the value of attribute stretch.
9 10 11 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 9 def stretch @stretch end |
#weight ⇒ Object
not used yet
10 11 12 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 10 def weight @weight end |
Class Method Details
.parallel(s1, s2) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 28 def Spring.parallel(s1,s2) pref = (s1.pref+s2.pref)*0.5 pref = [s1.min, pref].max pref = [s1.max, pref].min pref = [s2.min, pref].max pref = [s2.max, pref].min Spring.new( [s1.min,s2.min].max, [s1.shrink,s2.shrink].min, pref, [s1.stretch,s2.stretch].min, [s1.max,s2.max].min ) end |
Instance Method Details
#inspect ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/maruku/ext/diagrams/structures.rb', line 45 def inspect if @min == @max "Fixed(#{@min})" else "S[%.1f(%.1f)%.1f(%.1f)%.1f]=%.1f" % [ @min, @shrink, @pref, @stretch, @max, @imposed || -1] end end |