Class: RubySMB::SMB1::BitField::Open2AccessMode

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/ruby_smb/smb1/bit_field/open2_access_mode.rb

Overview

The AccessMode bit-field for an SMB1 Open2 Request as defined in 2.2.6.1.1 Request

Instance Method Summary collapse

Instance Method Details

#set_access_mode(mode = :r) ⇒ Object

Sets the #access_mode based on more human readableinput. Takes the symbols :r, :w, :rw, and :x to set Read, Write, ReadWrite, and Execute respectively.

Parameters:

  • mode (Symbol) (defaults to: :r)

    the access mode to set

Raises:

  • (ArgumentError)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ruby_smb/smb1/bit_field/open2_access_mode.rb', line 25

def set_access_mode(mode = :r)
  modes = [:r, :w, :rw, :x]
  raise ArgumentError, "Mode must be one of #{modes}" unless modes.include? mode
  case mode
  when :r
    self.access_mode = 0
  when :w
    self.access_mode = 1
  when :rw
    self.access_mode = 2
  when :x
    self.access_mode = 3
  end
end