class Ondotori::WebAPI::Api::DataRange
Attributes
from[R]
limit[R]
to[R]
Public Class Methods
new(from: nil, to: nil, limit: nil)
click to toggle source
# File lib/ondotori/webapi/api/data_range.rb, line 9 def initialize(from: nil, to: nil, limit: nil) validate(from, to, limit) @from = from @to = to @limit = limit.nil? ? 0 : [0, limit].max end
Public Instance Methods
add_data_range(params)
click to toggle source
# File lib/ondotori/webapi/api/data_range.rb, line 27 def add_data_range(params) params["unixtime-from"] = @from.to_i unless @from.nil? params["unixtime-to"] = @to.to_i unless @to.nil? params["number"] = @limit if @limit != 0 end
validate(from, to, _limit)
click to toggle source
# File lib/ondotori/webapi/api/data_range.rb, line 17 def validate(from, to, _limit) [from, to].each do |param| next if param.nil? || param.instance_of?(Time) raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new( "from and to parameter must be nil or Time.", 9992 ) end end