Class: UserAgent::Browsers::PlayStation
- Defined in:
- lib/user_agent/browsers/playstation.rb
Overview
Mozilla/5.0 (PLAYSTATION 3 4.75) AppleWebKit/531.22.8 (KHTML, like Gecko) Mozilla/5.0 (PLAYSTATION 3 4.76) AppleWebKit/531.22.8 (KHTML, like Gecko) Mozilla/5.0 (PLAYSTATION 3; 1.00) Mozilla/5.0 (PlayStation Vita 3.52) AppleWebKit/537.73 (KHTML, like Gecko) Silk/3.2 Mozilla/5.0 (PlayStation 4 2.57) AppleWebKit/537.73 (KHTML, like Gecko)
Class Method Summary collapse
Instance Method Summary collapse
-
#browser ⇒ nil, String
Returns the name of the browser in use.
-
#mobile? ⇒ true, false
PS Vita is mobile, others are not.
-
#os ⇒ String
Returns the operating system in use.
-
#platform ⇒ nil, ...
Returns the platform in use.
-
#version ⇒ nil, Version
Returns the browser version in use.
Methods inherited from Base
#<=>, #application, #bot?, #eql?, #method_missing, #respond_to?, #to_h, #to_s, #to_str
Methods included from Comparable
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class UserAgent::Browsers::Base
Class Method Details
.extend?(agent) ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'lib/user_agent/browsers/playstation.rb', line 9 def self.extend?(agent) !agent.application.nil? && !agent.application.comment.nil? && agent.application.comment.any? && ( agent.application.comment.first.include?('PLAYSTATION 3') || agent.application.comment.first.include?('PlayStation Vita') || agent.application.comment.first.include?('PlayStation 4') ) end |
Instance Method Details
#browser ⇒ nil, String
Returns the name of the browser in use.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/user_agent/browsers/playstation.rb', line 20 def browser if application.comment.first.include?('PLAYSTATION 3') 'PS3 Internet Browser' elsif last.product == 'Silk' 'Silk' elsif application.comment.first.include?('PlayStation 4') 'PS4 Internet Browser' else nil end end |
#mobile? ⇒ true, false
PS Vita is mobile, others are not.
35 36 37 |
# File 'lib/user_agent/browsers/playstation.rb', line 35 def mobile? platform == 'PlayStation Vita' end |
#os ⇒ String
Returns the operating system in use.
42 43 44 |
# File 'lib/user_agent/browsers/playstation.rb', line 42 def os application.comment.join(' ') end |
#platform ⇒ nil, ...
Returns the platform in use.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/user_agent/browsers/playstation.rb', line 49 def platform if os.include?('PLAYSTATION 3') 'PlayStation 3' elsif os.include?('PlayStation 4') 'PlayStation 4' elsif os.include?('PlayStation Vita') 'PlayStation Vita' else nil end end |
#version ⇒ nil, Version
Returns the browser version in use. If Silk, returns the version of Silk. Otherwise, returns the PS3/PS4 firmware version.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/user_agent/browsers/playstation.rb', line 65 def version if browser == 'Silk' last.version elsif platform == 'PlayStation 3' Version.new(os.split('PLAYSTATION 3 ').last) elsif platform == 'PlayStation 4' Version.new(os.split('PlayStation 4 ').last) elsif platform == 'PlayStation Vita' Version.new(os.split('PlayStation Vita ').last) else nil end end |