Class: Cdss::Models::Reading

Inherits:
Object
  • Object
show all
Includes:
Concerns::LogReadingAttributes, Concerns::WellReadingAttributes
Defined in:
lib/cdss/models/reading.rb

Constant Summary collapse

BASE_ATTRIBUTES =
%i[
  station_num
  station_number
  station_name
  site_id
  abbrev
  parameter
  usgs_site_id
  meas_type
  data_source
  modified
  metadata
  flags
  meas_date
  value
  meas_unit
  meas_value
  meas_date_time
  cal_year
  cal_month_num
  water_year
  min_q_cfs
  max_q_cfs
  avg_q_cfs
  total_q_af
  meas_count
  frost_date_32f_fall
  frost_date_32f_spring
  frost_date_28f_fall
  frost_date_28f_spring
].freeze
ATTRIBUTES =
(BASE_ATTRIBUTES + WELL_ATTRIBUTES + LOG_ATTRIBUTES).freeze

Constants included from Concerns::LogReadingAttributes

Concerns::LogReadingAttributes::LOG_ATTRIBUTES

Constants included from Concerns::WellReadingAttributes

Concerns::WellReadingAttributes::WELL_ATTRIBUTES

Instance Method Summary collapse

Methods included from Concerns::LogReadingAttributes

included, #log_reading?

Methods included from Concerns::WellReadingAttributes

included, #well_reading?

Constructor Details

#initialize(**attrs) ⇒ Reading

Returns a new instance of Reading.



45
46
47
48
49
50
51
# File 'lib/cdss/models/reading.rb', line 45

def initialize(**attrs)
  attrs[:metadata] ||= {}
  attrs[:flags] ||= {}
  ATTRIBUTES.each do |attr|
    instance_variable_set(:"@#{attr}", attrs[attr]) if attrs.key?(attr) && attrs[attr]
  end
end