class Brauser::Definitions::Platform

A definition of a platform.

@attribute [r] name

@return [String] The platform name.

@attribute [r] matcher

@return [Regexp|Proc] The pattern or the block to recognize the platform.

Attributes

matcher[R]
name[R]

Public Class Methods

new(id, name, matcher = /.*/, **_, &block) click to toggle source

Creates a new definition.

@param id [Symbol] The platform id. @param name [String] The platform name. @param matcher [Regexp|Proc] The pattern or the block to recognize the platform. **Ignored if a block is given.**

# File lib/brauser/definitions/platform.rb, line 22
def initialize(id, name, matcher = /.*/, **_, &block)
  @id = id
  @name = name
  @matcher = block ? block : matcher
end

Public Instance Methods

match(header, engine) click to toggle source

Matches against an header.

@param header [String] The header to match. @param engine [Symbol] The engine to match. @return [Boolean|NilClass] True if match succeeded, `false` or `nil` otherwise.

# File lib/brauser/definitions/platform.rb, line 33
def match(header, engine)
  if @matcher.is_a?(Regexp)
    @matcher.match(header)
  else
    @matcher.call(header, engine)
  end
end