Module: Brauser::Browseable::Register::ClassMethods
- Defined in:
- lib/brauser/browseable/register.rb
Overview
Class methods.
Instance Method Summary (collapse)
-
- (Boolean) add(type, definition)
Adds a definitions for recognition.
-
- (Boolean) add_default_browsers
Adds definitions for a default list of browsers that can be recognized.
-
- (Boolean) add_default_languages
Adds a default list of languages that can be recognized.
-
- (Boolean) add_default_platforms
Adds a default list of platforms that can be recognized.
Instance Method Details
- (Boolean) add(type, definition)
Adds a definitions for recognition.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/brauser/browseable/register.rb', line 21 def add(type, definition) rv = false if [:browsers, :platforms, :languages].include?(type) prepare_definitions_for(type) definition.ensure_array.each do |d| next unless d.is_a?(::Brauser::Definition) @definitions[type][d.tag] = d rv = true end end rv end |
- (Boolean) add_default_browsers
Adds definitions for a default list of browsers that can be recognized.
40 41 42 43 44 45 |
# File 'lib/brauser/browseable/register.rb', line 40 def add_default_browsers add(:browsers, ( ::Brauser::Browseable::DefaultDefinitions::MOBILE_BROWSERS + ::Brauser::Browseable::DefaultDefinitions::MAJOR_DESKTOP_BROWSERS + ::Brauser::Browseable::DefaultDefinitions::MSIE_BROWSERS + ::Brauser::Browseable::DefaultDefinitions::MINOR_DESKTOP_BROWSERS ).map { |browser| ::Brauser::Definition.send(:new, *browser) }) end |
- (Boolean) add_default_languages
Adds a default list of languages that can be recognized.
57 58 59 |
# File 'lib/brauser/browseable/register.rb', line 57 def add_default_languages add(:languages, ::Brauser::Browseable::DefaultDefinitions::LANGUAGES.map { |code, name| ::Brauser::Definition.new(code, name, code) }) end |
- (Boolean) add_default_platforms
Adds a default list of platforms that can be recognized.
50 51 52 |
# File 'lib/brauser/browseable/register.rb', line 50 def add_default_platforms add(:platforms, ::Brauser::Browseable::DefaultDefinitions::PLATFORMS.map { |platform| ::Brauser::Definition.send(:new, *platform) }) end |