Module: SpreeCmCommissioner::VideoOnDemandBitwise

Extended by:
ActiveSupport::Concern
Included in:
VideoOnDemand
Defined in:
app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb

Constant Summary collapse

QUALITY_BIT_FIELDS =

must add migration to cm_guests when adding new field.

{
  low: 0b1,           # quality_320p
  standard: 0b10,     # quality_480p
  medium: 0b100,      # quality_720p
  high: 0b1000        # quality_1080p
}.freeze
PROTOCOL_BIT_FIELDS =
{
  p_hls: 0b1,
  p_dash: 0b10,
  p_file: 0b100
}.freeze
DISPLAY_PROTOCOL_NAMES =
{
  p_hls: 'HLS',
  p_dash: 'DASH',
  p_file: 'File'
}.freeze

Instance Method Summary collapse

Instance Method Details

#protocol?Boolean

Returns:

  • (Boolean)


26
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 26

def protocol? = protocol != 0

#protocol_fieldsObject



56
57
58
59
60
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 56

def protocol_fields
  PROTOCOL_BIT_FIELDS.filter_map do |field, bit_value|
    field if video_protocol & bit_value != 0
  end
end

#protocol_fields_uppercaseObject



62
63
64
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 62

def protocol_fields_uppercase
  protocol_fields.map { |protocol| DISPLAY_PROTOCOL_NAMES[protocol] || protocol.to_s.upcase }
end

#quality?Boolean

Returns:

  • (Boolean)


25
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 25

def quality? = quality != 0

#quality_fieldsObject



35
36
37
38
39
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 35

def quality_fields
  QUALITY_BIT_FIELDS.filter_map do |field, bit_value|
    field if video_quality & bit_value != 0
  end
end

#quality_fields_uppercaseObject



45
46
47
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 45

def quality_fields_uppercase
  quality_fields.map(&:to_s).map(&:upcase)
end

#quality_value_enabled?(bit_value) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 41

def quality_value_enabled?(bit_value)
  video_quality & bit_value != 0
end