Module: Brauser::Definitions
- Defined in:
- lib/brauser/definitions/base.rb,
lib/brauser/definitions/browser.rb,
lib/brauser/definitions/platform.rb,
lib/brauser/definitions/language.rb
Overview
Definitions used by brauser.
Defined Under Namespace
Classes: Base, Browser, Language, Platform
Class Method Summary (collapse)
-
+ (Hash) browsers
Returns the list of browser that can be recognized.
-
+ (Hash) languages
Returns the list of languages that can be recognized.
-
+ (Hash) platforms
Returns the list of platforms that can be recognized.
-
+ (Object) register(type, *args, **kwargs, &block)
Registers a new definition.
Class Method Details
+ (Hash) browsers
Returns the list of browser that can be recognized.
The keys are the ids, the values are the definitions.
34 35 36 |
# File 'lib/brauser/definitions/base.rb', line 34 def self.browsers @definitions[:browsers] end |
+ (Hash) languages
Returns the list of languages that can be recognized.
The keys are the ids, the values are the definitions.
52 53 54 |
# File 'lib/brauser/definitions/base.rb', line 52 def self.languages @definitions[:languages] end |
+ (Hash) platforms
Returns the list of platforms that can be recognized.
The keys are the ids, the values are the definitions.
43 44 45 |
# File 'lib/brauser/definitions/base.rb', line 43 def self.platforms @definitions[:platforms] end |
+ (Object) register(type, *args, **kwargs, &block)
Registers a new definition.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/brauser/definitions/base.rb', line 15 def self.register(type, *args, **kwargs, &block) klass = case type when :browser then Brauser::Definitions::Browser when :language then Brauser::Definitions::Language when :platform then Brauser::Definitions::Platform else raise(ArgumentError, "Invalid definition type \"#{type}\".") end @definitions ||= {browsers: {}, languages: {}, platforms: {}} definition = klass.new(*args, **kwargs, &block) @definitions["#{type}s".to_sym][definition.id] = definition end |