Module: Brauser::BrowserMethods::Attributes
- Included in:
- Brauser::Browser
- Defined in:
- lib/brauser/browser.rb
Overview
Methods to handle attributes
Instance Method Summary (collapse)
-
- (String|Array) classes(join = " ", name = "", version = "version-", platform = "platform-", &block)
(also: #meta)
Returns an array of information about the browser.
-
- (String) platform_name
Gets a human-readable platform name.
-
- (String) readable_name
Gets a human-readable browser name.
Instance Method Details
- (String|Array) classes(join = " ", name = "", version = "version-", platform = "platform-", &block) Also known as: meta
Returns an array of information about the browser. Information are strings which are suitable to use as CSS classes.
For version, it will be included a class for every token of the version. For example, version 7.0.1.2
will return this:
ruby
["version-7", "version-7_0", "version-7_0_1", "version-7_0_1_2"]
If you provide a block (with accepts name, version and platform as arguments), it will be used for translating the name.
385 386 387 388 389 |
# File 'lib/brauser/browser.rb', line 385 def classes(join = " ", name = "", version = "version-", platform = "platform-", &block) platform = "platform-" if platform.is_a?(TrueClass) rv = [stringify_name(name, &block), stringify_version(version), !platform ? nil : (platform + @platform.to_s)].compact.flatten join ? rv.join(join) : rv end |
- (String) platform_name
Gets a human-readable platform name.
364 365 366 367 |
# File 'lib/brauser/browser.rb', line 364 def platform_name parse_agent(@agent) if !@platform ::Brauser::Browser.platforms[@platform].try(:label) || "Unknown Platform" end |
- (String) readable_name
Gets a human-readable browser name.
356 357 358 359 |
# File 'lib/brauser/browser.rb', line 356 def readable_name parse_agent(@agent) if !@name ::Brauser::Browser.browsers[@name].try(:label) || "Unknown Browser" end |