On Fri, Dec 28, 2012 at 1:00 AM, Brandon Weaver <[email protected]> wrote:
> I've already sorted them into classes and objects, so instance variables are
> created for every antenna and other such things.

The more I think about it the more I do believe it is responsibility
of the "driver" (i.e. the bit that fetches the data) to return _proper
data_.  In this case it would mean: do not return numbers as strings.
If values are invalid return a special value for that; this value
could be nil or one or more symbols depending on how many states need
to be represented.

The using code should expect data properly typed so it can do its business.

Another thought: if you create instance variables on the fly for
sensors then a Hash is probably a better alternative.  You could use a
specific class as values which encapsulates the data along with meta
data (valid, available, taken at...).  Example

SensorData = Struct.new :name, :value, :taken_at do
  def valid?
    value # nil is invalid
  end
end

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to