class DeviceDetector::MetadataExtractor

Public Instance Methods

call() click to toggle source
# File lib/device_detector/metadata_extractor.rb, line 5
def call
  regex_meta.any? ? extract_metadata : nil
end

Private Instance Methods

extract_metadata() click to toggle source
# File lib/device_detector/metadata_extractor.rb, line 16
def extract_metadata
  user_agent.match(regex) do |match_data|
    metadata_string.gsub(/\$(\d)/) do
      match_data[Regexp.last_match(1).to_i].to_s
    end.strip
  end
end
metadata_string() click to toggle source
# File lib/device_detector/metadata_extractor.rb, line 11
def metadata_string
  message = "#{name} (a child of MetadataExtractor) must implement the '#{__method__}' method."
  raise NotImplementedError, message
end
regex() click to toggle source
# File lib/device_detector/metadata_extractor.rb, line 24
def regex
  @regex ||= regex_meta[:regex]
end