Class: TCD::Constituent
- Inherits:
-
Struct
- Object
- Struct
- TCD::Constituent
- Defined in:
- lib/tcd/constituent.rb
Overview
Data structure for tidal constituent information. Each constituent has a speed and year-indexed equilibrium/node factor arrays.
Instance Attribute Summary collapse
-
#equilibrium ⇒ Object
Returns the value of attribute equilibrium.
-
#index ⇒ Object
Returns the value of attribute index.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node_factors ⇒ Object
Returns the value of attribute node_factors.
-
#speed ⇒ Object
Returns the value of attribute speed.
Instance Method Summary collapse
-
#equilibrium_for_year(year, start_year) ⇒ Object
Get equilibrium argument for a specific year.
-
#node_factor_for_year(year, start_year) ⇒ Object
Get node factor for a specific year.
- #to_s ⇒ Object
Instance Attribute Details
#equilibrium ⇒ Object
Returns the value of attribute equilibrium
6 7 8 |
# File 'lib/tcd/constituent.rb', line 6 def equilibrium @equilibrium end |
#index ⇒ Object
Returns the value of attribute index
6 7 8 |
# File 'lib/tcd/constituent.rb', line 6 def index @index end |
#name ⇒ Object
Returns the value of attribute name
6 7 8 |
# File 'lib/tcd/constituent.rb', line 6 def name @name end |
#node_factors ⇒ Object
Returns the value of attribute node_factors
6 7 8 |
# File 'lib/tcd/constituent.rb', line 6 def node_factors @node_factors end |
#speed ⇒ Object
Returns the value of attribute speed
6 7 8 |
# File 'lib/tcd/constituent.rb', line 6 def speed @speed end |
Instance Method Details
#equilibrium_for_year(year, start_year) ⇒ Object
Get equilibrium argument for a specific year
15 16 17 18 19 |
# File 'lib/tcd/constituent.rb', line 15 def equilibrium_for_year(year, start_year) idx = year - start_year return nil if idx < 0 || idx >= equilibrium.size equilibrium[idx] end |
#node_factor_for_year(year, start_year) ⇒ Object
Get node factor for a specific year
22 23 24 25 26 |
# File 'lib/tcd/constituent.rb', line 22 def node_factor_for_year(year, start_year) idx = year - start_year return nil if idx < 0 || idx >= node_factors.size node_factors[idx] end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/tcd/constituent.rb', line 28 def to_s "#{name}: #{format('%.7f', speed)}°/hr" end |