Class: PlatformGuard

Inherits:
SpecGuard show all
Defined in:
lib/mspec/guards/platform.rb

Instance Method Summary collapse

Methods inherited from SpecGuard

#===, #after, #before, finish, #implementation?, #os?, #platform?, register, #unregister, unregister, #windows?, #wordsize?, #yield?

Constructor Details

#initialize(*args) ⇒ PlatformGuard

Returns a new instance of PlatformGuard.



4
5
6
7
8
9
10
# File 'lib/mspec/guards/platform.rb', line 4

def initialize(*args)
  if args.last.is_a?(Hash)
    @options, @platforms = args.last, args[0..-2]
  else
    @options, @platforms = {}, args
  end
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mspec/guards/platform.rb', line 12

def match?
  match = @platforms.empty? ? true : platform?(*@platforms)
  @options.each do |key, value|
    case key
    when :os
      match &&= os?(*value)
    when :wordsize
      match &&= wordsize? value
    end
  end
  match
end