Class: TurboRex::MSRPC::RPCBase::MIDL_SWITCHES
- Inherits:
-
Object
- Object
- TurboRex::MSRPC::RPCBase::MIDL_SWITCHES
- Defined in:
- lib/turborex/msrpc/rpcbase.rb
Constant Summary collapse
- SWITCHES =
%w[Oi Oic Oif Oicf Os ndr64 all win64 amd64 ia64]
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #add(switch) ⇒ Object (also: #<<)
- #arch_64? ⇒ Boolean
- #has_all_of_switches?(switch) ⇒ Boolean
- #has_one_of_switches?(switch) ⇒ Boolean
- #has_switch?(switch) ⇒ Boolean
-
#initialize ⇒ MIDL_SWITCHES
constructor
A new instance of MIDL_SWITCHES.
- #mapping_midl_switch(switch) ⇒ Object
- #remove(switch) ⇒ Object
- #to_array ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ MIDL_SWITCHES
Returns a new instance of MIDL_SWITCHES.
327 328 329 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 327 def initialize @value = 0 end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
325 326 327 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 325 def value @value end |
Instance Method Details
#add(switch) ⇒ Object Also known as: <<
331 332 333 334 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 331 def add(switch) return @value if has_switch?(switch) @value |= mapping_midl_switch(switch) end |
#arch_64? ⇒ Boolean
356 357 358 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 356 def arch_64? has_one_of_switches?(%w[win64 amd64 ia64]) end |
#has_all_of_switches?(switch) ⇒ Boolean
350 351 352 353 354 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 350 def has_all_of_switches?(switch) res = true switch.map {|s|res = false unless has_switch?(s)} res end |
#has_one_of_switches?(switch) ⇒ Boolean
345 346 347 348 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 345 def has_one_of_switches?(switch) switch.each { |s| return true if has_switch?(s) } false end |
#has_switch?(switch) ⇒ Boolean
340 341 342 343 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 340 def has_switch?(switch) integer = mapping_midl_switch(switch) !integer.zero? && (@value & integer) == integer end |
#mapping_midl_switch(switch) ⇒ Object
360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 360 def mapping_midl_switch(switch) switch = [switch] if switch.is_a?(String) case switch when Array (switch & SWITCHES).map do |s| 2**SWITCHES.index(s) end.inject(0, :+) when Integer SWITCHES.reject do |s| ((switch || 0) & 2**SWITCHES.index(s)).zero? end end end |
#remove(switch) ⇒ Object
336 337 338 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 336 def remove(switch) @value &= ~mapping_midl_switch(switch) end |
#to_array ⇒ Object
374 375 376 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 374 def to_array mapping_midl_switch(@value) end |
#to_s ⇒ Object
378 379 380 |
# File 'lib/turborex/msrpc/rpcbase.rb', line 378 def to_s mapping_midl_switch(@value).join(', ') end |