Class: RubySMB::Field::Utime

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/ruby_smb/field/utime.rb

Overview

Conveneince class for dealing with 32-bit unsigned UTIME fields in SMB, as defined in 2.2.1.4.3 UTIME

Instance Method Summary collapse

Instance Method Details

#getBinData::Bit32

Gets the value of the field

Returns:

  • (BinData::Bit32)

    the 64-bit value of the field



14
15
16
# File 'lib/ruby_smb/field/utime.rb', line 14

def get
  val
end

#set(value) ⇒ Object

Sets the value of the field from a DateTime,Time,Fixnum, or object that can be converted to an integer. Any other parameter passed in will be assumed to already be correct.

Parameters:

  • value (DateTime, Time, Fixnum, #to_i)

    the value to set

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ruby_smb/field/utime.rb', line 24

def set(value)
  case value
    when DateTime
      set(value.to_time)
    when Time
      set(value.to_i)
    when Fixnum
      self.val = value
    else
      self.val = value.to_i
  end
  val
end

#to_datetimeDateTime

Returns the value of the field as a DateTime

Returns:

  • (DateTime)

    the DateTime representation of the current value



41
42
43
44
# File 'lib/ruby_smb/field/utime.rb', line 41

def to_datetime
  time = to_time
  time.to_datetime
end

#to_timeTime

Returns the value of the field as a Time

Returns:

  • (Time)

    the Time representation of the current value



49
50
51
# File 'lib/ruby_smb/field/utime.rb', line 49

def to_time
  Time.at val
end