Module: SGC::Helper::FlagsValue
- Included in:
- CU::API::Enum, Cuda::API::Enum
- Defined in:
- lib/helpers/flags.rb
Overview
Provide methods for evaluating the composite value of flags. self which include/extend this module should implement IEnum interface.
Defined Under Namespace
Modules: Pvt
Instance Method Summary collapse
-
#value(*flags) ⇒ Integer
The composite value of the flags with respect to self.
Instance Method Details
#value(*flags) ⇒ Integer
Returns The composite value of the flags with respect to self.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/helpers/flags.rb', line 46 def value(*flags) flags.empty? == false or raise ArgumentError, "No flags is provided. Expect Array<Symbol, Integer>, Symbol or Integer." f = 0 flags.flatten.each do |x| case x when Symbol v = self[x] or Pvt::raise_invalid_symbol(x) f |= v when Integer self[x] or Pvt::raise_invalid_value(x) f |= x else raise ArgumentError, "Invalid flags: #{x.to_s}. Expect Symbol or Integer in the flags array." end end f end |