Class: DeviceDetector::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/device_detector/parser.rb

Direct Known Subclasses

Bot, Client, Device, OS, VendorFragment

Constant Summary collapse

ROOT =
File.expand_path('../..', __dir__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_agent) ⇒ Parser

Returns a new instance of Parser.



10
11
12
# File 'lib/device_detector/parser.rb', line 10

def initialize(user_agent)
  @user_agent = user_agent
end

Instance Attribute Details

#user_agentObject (readonly)

Returns the value of attribute user_agent.



14
15
16
# File 'lib/device_detector/parser.rb', line 14

def user_agent
  @user_agent
end

Instance Method Details

#full_versionObject



22
23
24
25
26
# File 'lib/device_detector/parser.rb', line 22

def full_version
  from_cache(['full_version', self.class.name, user_agent]) do
    VersionExtractor.new(user_agent, regex_meta).call
  end
end

#nameObject



16
17
18
19
20
# File 'lib/device_detector/parser.rb', line 16

def name
  from_cache(['name', self.class.name, user_agent]) do
    NameExtractor.new(user_agent, regex_meta).call
  end
end