Class: FidoMetadata::Coercer::BitField
- Inherits:
-
Object
- Object
- FidoMetadata::Coercer::BitField
- Defined in:
- lib/fido_metadata/coercer/bit_field.rb
Instance Method Summary collapse
- #coerce(value) ⇒ Object
-
#initialize(mapping, single_value: false) ⇒ BitField
constructor
A new instance of BitField.
Constructor Details
#initialize(mapping, single_value: false) ⇒ BitField
Returns a new instance of BitField.
6 7 8 9 |
# File 'lib/fido_metadata/coercer/bit_field.rb', line 6 def initialize(mapping, single_value: false) @mapping = mapping @single_value = single_value end |
Instance Method Details
#coerce(value) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/fido_metadata/coercer/bit_field.rb', line 11 def coerce(value) results = @mapping.reject { |flag, _constant| flag & value == 0 }.values if @single_value results.first else results end end |