Class: StructuraidCore::Elements::Reinforcement::StraightLongitudinal
- Defined in:
- lib/structuraid_core/elements/reinforcement/straight_longitudinal.rb
Instance Attribute Summary collapse
-
#layers ⇒ Object
readonly
Returns the value of attribute layers.
Instance Method Summary collapse
- #add_layer(start_location:, end_location:, amount_of_rebars:, rebar:) ⇒ Object
- #area ⇒ Object
- #centroid_height ⇒ Object
- #inertia ⇒ Object
-
#initialize(distribution_direction:, above_middle: false) ⇒ StraightLongitudinal
constructor
A new instance of StraightLongitudinal.
Constructor Details
#initialize(distribution_direction:, above_middle: false) ⇒ StraightLongitudinal
Returns a new instance of StraightLongitudinal.
7 8 9 10 11 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal.rb', line 7 def initialize(distribution_direction:, above_middle: false) @above_middle = above_middle @layers = [] @distribution_direction = distribution_direction end |
Instance Attribute Details
#layers ⇒ Object (readonly)
Returns the value of attribute layers.
5 6 7 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal.rb', line 5 def layers @layers end |
Instance Method Details
#add_layer(start_location:, end_location:, amount_of_rebars:, rebar:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal.rb', line 13 def add_layer(start_location:, end_location:, amount_of_rebars:, rebar:) new_layer = Elements::Reinforcement::StraightLongitudinalLayer.new( start_location:, end_location:, amount_of_rebars:, rebar:, distribution_direction: @distribution_direction ) new_layer.reposition(above_middle: @above_middle) @layers << new_layer new_layer end |
#area ⇒ Object
34 35 36 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal.rb', line 34 def area @layers.map(&:area).reduce(:+) end |
#centroid_height ⇒ Object
28 29 30 31 32 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal.rb', line 28 def centroid_height return inertia / area unless @layers.empty? raise Elements::Reinforcement::EmptyLayers, "can't complete centroid height calculation" end |
#inertia ⇒ Object
38 39 40 |
# File 'lib/structuraid_core/elements/reinforcement/straight_longitudinal.rb', line 38 def inertia @layers.map(&:inertia).reduce(:+) end |