Class: TCD::Constituent

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#equilibriumObject

Returns the value of attribute equilibrium

Returns:

  • (Object)

    the current value of equilibrium



6
7
8
# File 'lib/tcd/constituent.rb', line 6

def equilibrium
  @equilibrium
end

#indexObject

Returns the value of attribute index

Returns:

  • (Object)

    the current value of index



6
7
8
# File 'lib/tcd/constituent.rb', line 6

def index
  @index
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/tcd/constituent.rb', line 6

def name
  @name
end

#node_factorsObject

Returns the value of attribute node_factors

Returns:

  • (Object)

    the current value of node_factors



6
7
8
# File 'lib/tcd/constituent.rb', line 6

def node_factors
  @node_factors
end

#speedObject

Returns the value of attribute speed

Returns:

  • (Object)

    the current value of 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_sObject



28
29
30
# File 'lib/tcd/constituent.rb', line 28

def to_s
    "#{name}: #{format('%.7f', speed)}°/hr"
end