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
- #protocol? ⇒ Boolean
- #protocol_fields ⇒ Object
- #protocol_fields_uppercase ⇒ Object
- #quality? ⇒ Boolean
- #quality_fields ⇒ Object
- #quality_fields_uppercase ⇒ Object
- #quality_value_enabled?(bit_value) ⇒ Boolean
Instance Method Details
#protocol? ⇒ Boolean
26 |
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 26 def protocol? = protocol != 0 |
#protocol_fields ⇒ Object
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_uppercase ⇒ Object
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
25 |
# File 'app/models/concerns/spree_cm_commissioner/video_on_demand_bitwise.rb', line 25 def quality? = quality != 0 |
#quality_fields ⇒ Object
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_uppercase ⇒ Object
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
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 |