Class: PlatformGuard

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

Instance Attribute Summary

Attributes inherited from SpecGuard

#name, #parameters

Instance Method Summary collapse

Methods inherited from SpecGuard

#===, #add, clear, clear_guards, finish, guards, #implementation?, #os?, #platform?, #record, report, #report_key, #reporting?, ruby_version, #standard?, #unregister, windows?, #windows?, #wordsize?, #yield?

Constructor Details

#initialize(*args) ⇒ PlatformGuard

Returns a new instance of PlatformGuard.



4
5
6
7
8
9
10
11
# 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
  self.parameters = args
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


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

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