Class: EhbrsRubyUtils::Videos::Quality

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/ehbrs_ruby_utils/videos/quality.rb

Constant Summary collapse

POSITIVE_MARGIN =
0.75
LIST =
[240, 480, 720, 1080, 2160].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#followingObject

Returns the value of attribute following.



29
30
31
# File 'lib/ehbrs_ruby_utils/videos/quality.rb', line 29

def following
  @following
end

Class Method Details

.by_height(height) ⇒ Object



17
18
19
# File 'lib/ehbrs_ruby_utils/videos/quality.rb', line 17

def by_height(height)
  list.find { |v| v.height == height }
end

Instance Method Details

#<=>(other) ⇒ Object



35
36
37
# File 'lib/ehbrs_ruby_utils/videos/quality.rb', line 35

def <=>(other)
  height <=> other.height
end

#resolution_match?(resolution) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
# File 'lib/ehbrs_ruby_utils/videos/quality.rb', line 45

def resolution_match?(resolution)
  (min_height.blank? || resolution.lower >= min_height) &&
    (max_height.blank? || resolution.lower <= max_height)
end

#to_xsObject



41
42
43
# File 'lib/ehbrs_ruby_utils/videos/quality.rb', line 41

def to_xs
  "#{height} (Min: #{min_height}, Max: #{max_height})"
end