Class: Ondotori::WebAPI::Api::DataParams

Inherits:
ParamsBase
  • Object
show all
Defined in:
lib/ondotori/webapi/api/params.rb

Direct Known Subclasses

DataRTR500Params

Instance Method Summary collapse

Constructor Details

#initialize(param, serial, data_range: nil) ⇒ DataParams

Returns a new instance of DataParams.



84
85
86
87
88
89
# File 'lib/ondotori/webapi/api/params.rb', line 84

def initialize(param, serial, data_range: nil)
  super(param)
  validate(serial)
  @data_range = data_range
  @serial = serial
end

Instance Method Details

#to_ondotori_paramObject



99
100
101
102
103
104
105
# File 'lib/ondotori/webapi/api/params.rb', line 99

def to_ondotori_param
  params = super
  params["remote-serial"] = @serial
  @data_range&.add_data_range(params)

  params
end

#validate(serial) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/ondotori/webapi/api/params.rb', line 91

def validate(serial)
  unless serial.instance_of?(String)
    raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new(
      "serial must be String.", 9991
    )
  end
end