On Mar 3, 6:08 pm, Gordon Thiesfeld <
gthiesf...@gmail.com> wrote:
> But, I thought I'd like it to look like this:
>
> range = start..stop
> events = WMI::Win32_NTLogEvent.select{ |e| range.include?
> e.timewritten }
>
> and produce this query:
> "SELECT * FROM Win32_NTLogEvent WHERE (timewritten >=
> '20080302000000.000000-360' AND timewritten <
> '20080303000000.000000-360')"
>
> I've actually written the code to wire this up. I can't see any
> reason not to do this, but I'm certainly no expert. I'd like to hear
> other opinions.
OK, I forgot to take into account the 2 dot or 3 dot ranges (include
exclude end). Here are my updated specs:
specify "range: (lo..hi).include? item" do
lo = 3
hi = 5
wql = @klass.select { |m| (lo..hi).include? m.drivetype }
wql.to_s.should == "SELECT * FROM Win32_LogicalDisk WHERE
(drivetype >= '3' AND drivetype <= '5')"
end
specify "range: (lo...hi).include? item" do
lo = 3
hi = 5
wql = @klass.select { |m| (lo...hi).include? m.drivetype }
wql.to_s.should == "SELECT * FROM Win32_LogicalDisk WHERE
(drivetype >= '3' AND drivetype < '5')"
end