class UserAgent::Browsers::Webkit

def self.extend?(agent)

def self.extend?(agent)
  agent.detect { |useragent| useragent.product =~ /\AAppleWebKit\z/i }
end

def application

def application
   self.reject { |agent| agent.comment.nil? || agent.comment.empty? }.first
end

def browser

def browser
  if os =~ /Android/
    'Android'
  elsif platform == 'BlackBerry'
    platform
  else
    'Safari'
  end
end

def build

def build
  webkit.version
end

def localization

def localization
  if application.nil?
    nil
  else
    application.comment[3]
  end
end

def os

def os
  if application
    if application.comment[0] =~ /Windows NT/
      OperatingSystems.normalize_os(application.comment[0])
    elsif application.comment[2].nil?
      OperatingSystems.normalize_os(application.comment[1])
    elsif application.comment[1] =~ /Android/
      OperatingSystems.normalize_os(application.comment[1])
    elsif (os_string = application.comment.detect { |c| c =~ OperatingSystems::IOS_VERSION_REGEX })
      OperatingSystems.normalize_os(os_string)
    else
      OperatingSystems.normalize_os(application.comment[2])
    end
  else
    nil
  end
end

def platform

def platform
  if application.nil?
    nil
  elsif application.comment[0] =~ /Windows/
    'Windows'
  elsif application.comment[0] == 'BB10'
    'BlackBerry'
  elsif application.comment.any? { |c| c =~ /Android/ }
    'Android'
  else
    application.comment[0]
  end
end

def security

def security
  Security[application.comment[1]]
end

def version

Prior to Safari 3, the user agent did not include a version number
def version
  str = if product = detect_product('Version')
    product.version
  elsif os =~ /iOS ([\d\.]+)/ && browser == "Safari"
    $1.gsub(/_/, '.')
  else
    BuildVersions[build.to_s]
  end
  Version.new(str)
end

def webkit

def webkit
  detect { |useragent| useragent.product =~ /\AAppleWebKit\z/i }
end