Module: Brauser::BrowserMethods::Register::ClassMethods
- Defined in:
- lib/brauser/browser.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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/brauser/browser.rb', line 22 def add(type, definition) rv = false if [:browsers, :platforms, :languages].include?(type) then @definitions ||= {} @definitions[type] ||= {} definition.ensure_array.each do |d| if d.is_a?(::Brauser::Definition) then @definitions[type][d.tag] = d rv = true end end end rv end |
- (Boolean) add_default_browsers
Adds definitions for a default list of browsers that can be recognized.
43 44 45 |
# File 'lib/brauser/browser.rb', line 43 def add_default_browsers add_mobile_browsers && add_major_desktop_browsers && add_msie_browsers && add_minor_desktop_browsers end |
- (Boolean) add_default_languages
Adds a default list of languages that can be recognized.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/brauser/browser.rb', line 71 def add_default_languages add(:languages, { "af" => "Afrikaans", "sq" => "Albanian", "eu" => "Basque", "bg" => "Bulgarian", "be" => "Byelorussian", "ca" => "Catalan", "zh" => "Chinese", "zh-cn" => "Chinese/China", "zh-tw" => "Chinese/Taiwan", "zh-hk" => "Chinese/Hong Kong", "zh-sg" => "Chinese/singapore", "hr" => "Croatian", "cs" => "Czech", "da" => "Danish", "nl" => "Dutch", "nl-nl" => "Dutch/Netherlands", "nl-be" => "Dutch/Belgium", "en" => "English", "en-gb" => "English/United Kingdom", "en-us" => "English/United States", "en-au" => "English/Australian", "en-ca" => "English/Canada", "en-nz" => "English/New Zealand", "en-ie" => "English/Ireland", "en-za" => "English/South Africa", "en-jm" => "English/Jamaica", "en-bz" => "English/Belize", "en-tt" => "English/Trinidad", "et" => "Estonian", "fo" => "Faeroese", "fa" => "Farsi", "fi" => "Finnish", "fr" => "French", "fr-be" => "French/Belgium", "fr-fr" => "French/France", "fr-ch" => "French/Switzerland", "fr-ca" => "French/Canada", "fr-lu" => "French/Luxembourg", "gd" => "Gaelic", "gl" => "Galician", "de" => "German", "de-at" => "German/Austria", "de-de" => "German/Germany", "de-ch" => "German/Switzerland", "de-lu" => "German/Luxembourg", "de-li" => "German/Liechtenstein", "el" => "Greek", "he" => "Hebrew", "he-il" => "Hebrew/Israel", "hi" => "Hindi", "hu" => "Hungarian", "ie-ee" => "Internet Explorer/Easter Egg", "is" => "Icelandic", "id" => "Indonesian", "in" => "Indonesian", "ga" => "Irish", "it" => "Italian", "it-ch" => "Italian/ Switzerland", "ja" => "Japanese", "km" => "Khmer", "km-kh" => "Khmer/Cambodia", "ko" => "Korean", "lv" => "Latvian", "lt" => "Lithuanian", "mk" => "Macedonian", "ms" => "Malaysian", "mt" => "Maltese", "no" => "Norwegian", "pl" => "Polish", "pt" => "Portuguese", "pt-br" => "Portuguese/Brazil", "rm" => "Rhaeto-Romanic", "ro" => "Romanian", "ro-mo" => "Romanian/Moldavia", "ru" => "Russian", "ru-mo" => "Russian /Moldavia", "sr" => "Serbian", "sk" => "Slovack", "sl" => "Slovenian", "sb" => "Sorbian", "es" => "Spanish", "es-do" => "Spanish", "es-ar" => "Spanish/Argentina", "es-co" => "Spanish/Colombia", "es-mx" => "Spanish/Mexico", "es-es" => "Spanish/Spain", "es-gt" => "Spanish/Guatemala", "es-cr" => "Spanish/Costa Rica", "es-pa" => "Spanish/Panama", "es-ve" => "Spanish/Venezuela", "es-pe" => "Spanish/Peru", "es-ec" => "Spanish/Ecuador", "es-cl" => "Spanish/Chile", "es-uy" => "Spanish/Uruguay", "es-py" => "Spanish/Paraguay", "es-bo" => "Spanish/Bolivia", "es-sv" => "Spanish/El salvador", "es-hn" => "Spanish/Honduras", "es-ni" => "Spanish/Nicaragua", "es-pr" => "Spanish/Puerto Rico", "sx" => "Sutu", "sv" => "Swedish", "sv-se" => "Swedish/Sweden", "sv-fi" => "Swedish/Finland", "ts" => "Thai", "tn" => "Tswana", "tr" => "Turkish", "uk" => "Ukrainian", "ur" => "Urdu", "vi" => "Vietnamese", "xh" => "Xshosa", "ji" => "Yiddish", "zu" => "Zulu" }.collect { |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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/brauser/browser.rb', line 50 def add_default_platforms add(:platforms, [ [:symbian, "Symbian", /s60|symb/i], [:windows_phone, "Microsoft Windows Phone", /windows phone/i], [:kindle, "Nokia Symbian", /kindle|silk/i, ], [:ios, "Apple iOS", Proc.new { |_, agent| [:iphone, :ipad, :ipod].include?(name) || agent =~ /ipad|iphone|ipod/i }], [:android, "Android", /android/i], [:blackberry, "RIM BlackBerry", /blackberry/i], [:psp, "Sony Playstation Portable", /psp/i], [:ps3, "Sony Playstation 3", /playstation 3/i], [:wii, "Nintendo Wii", /wii/i], [:linux, "Linux", /linux/i], [:osx, "Apple MacOS X", /mac|macintosh|mac os x/i], [:windows, "Microsoft Windows", /windows/i] ].collect { |platform| ::Brauser::Definition.send(:new, *platform) }) end |