Class: CanIUse::BrowserVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/can_i_use/browser_version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_string, support_string) ⇒ BrowserVersion



8
9
10
11
# File 'lib/can_i_use/browser_version.rb', line 8

def initialize(version_string, support_string)
  @version_string = version_string
  @support_string = support_string
end

Instance Attribute Details

#support_stringObject

Returns the value of attribute support_string.



4
5
6
# File 'lib/can_i_use/browser_version.rb', line 4

def support_string
  @support_string
end

#version_stringObject

Returns the value of attribute version_string.



3
4
5
# File 'lib/can_i_use/browser_version.rb', line 3

def version_string
  @version_string
end

Instance Method Details

#<(other) ⇒ Object



27
28
29
# File 'lib/can_i_use/browser_version.rb', line 27

def <(other)
  Gem::Version.new(to_s.dup) < Gem::Version.new(other.to_s.dup)
end

#<=(other) ⇒ Object



31
32
33
# File 'lib/can_i_use/browser_version.rb', line 31

def <=(other)
  Gem::Version.new(to_s.dup) <= Gem::Version.new(other.to_s.dup)
end

#<=>(other) ⇒ Object




15
16
17
# File 'lib/can_i_use/browser_version.rb', line 15

def <=>(other)
  Gem::Version.new(to_s.dup) <=> Gem::Version.new(other.to_s.dup)
end

#==(other) ⇒ Object



35
36
37
# File 'lib/can_i_use/browser_version.rb', line 35

def ==(other)
  Gem::Version.new(to_s.dup) == Gem::Version.new(other.to_s.dup)
end

#>(other) ⇒ Object



19
20
21
# File 'lib/can_i_use/browser_version.rb', line 19

def >(other)
  Gem::Version.new(to_s.dup) > Gem::Version.new(other.to_s.dup)
end

#>=(other) ⇒ Object



23
24
25
# File 'lib/can_i_use/browser_version.rb', line 23

def >=(other)
  Gem::Version.new(to_s.dup) >= Gem::Version.new(other.to_s.dup)
end

#support_typeObject

TODO: append note



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/can_i_use/browser_version.rb', line 57

def support_type
  case
  when support_string =~ /y/i then :yes
  when support_string =~ /a/i then :almost
  when support_string =~ /n/i then :no
  when support_string =~ /p/i then :polyfill
  when support_string =~ /u/i then :unknown
  when support_string =~ /x/i then :prefix
  when support_string =~ /d/i then :disabled
  end
end

#to_sObject




41
42
43
# File 'lib/can_i_use/browser_version.rb', line 41

def to_s
  @version_string
end