class Cani::Api::Browser

Constants

ABBR_MAP
LABEL_MAP

Attributes

abbr[R]
eras[R]
label[R]
name[R]
prefix[R]
title[R]
type[R]
usage[R]
versions[R]

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/cani/api/browser.rb, line 28
def initialize(attributes = {})
  abbr = attributes['abbr'].downcase.gsub(/^\.+|\.+$/, '').tr '/', '.'

  @abbr     = ABBR_MAP.fetch abbr, abbr
  @label    = LABEL_MAP.fetch abbr, abbr
  @name     = attributes[:name].downcase
  @title    = attributes['browser'].downcase
  @prefix   = attributes['prefix'].downcase
  @type     = attributes['type'].downcase
  @usage    = attributes['usage_global'].each_with_object({}) do |(v, u), h|
    v.split('-').each { |ver| h[ver] = u }
  end
  @eras = attributes['versions'].each_with_object([]) do |v, a|
    if v
      v.split('-').each { |ver| a << ver }
    else
      a << v
    end
  end
  @versions = @usage.keys
  @features = {}
end

Public Instance Methods

features_for(version) click to toggle source
# File lib/cani/api/browser.rb, line 59
def features_for(version)
  @features[version] ||= Cani.api.features.each_with_object({}) do |ft, h|
    type = ft.support_in name, version
    (h[type] ||= []) << { support: type, title: ft.title,
                          status: ft.status, percent: ft.percent }
  end
end
max_column_width() click to toggle source
# File lib/cani/api/browser.rb, line 55
def max_column_width
  [name.size, versions.map(&:size).max].max
end