Class: RCL::Timestamp

Inherits:
Object show all
Defined in:
lib/rcl/timestamp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTimestamp

Returns a new instance of Timestamp.



10
11
12
13
14
15
16
# File 'lib/rcl/timestamp.rb', line 10

def initialize
  @create = Time.now
  @modify = nil
  @access = nil

  nil
end

Instance Attribute Details

#accessObject (readonly)

Returns the value of attribute access.



8
9
10
# File 'lib/rcl/timestamp.rb', line 8

def access
  @access
end

#createObject (readonly)

Returns the value of attribute create.



8
9
10
# File 'lib/rcl/timestamp.rb', line 8

def create
  @create
end

#modifyObject (readonly)

Returns the value of attribute modify.



8
9
10
# File 'lib/rcl/timestamp.rb', line 8

def modify
  @modify
end

Instance Method Details

#dump(indent = 0, stream = STDOUT) ⇒ Object

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rcl/timestamp.rb', line 37

def dump(indent=0, stream=STDOUT)
  raise ArgumentError, 'nil indent' if indent.nil?
  raise ArgumentError, 'invalid indent class' if indent.class != Fixnum
  raise ArgumentError, 'indent range error' if indent < 0
  raise ArgumentError, 'nil stream' if stream.nil?
  raise ArgumentError, 'invalid stream class' if stream.class != IO

  # instance
  indent.times { stream << ' ' }
  stream << "#{self.class}<#{self.object_id}> instance:\n"

  indent += 2

  # create
  indent.times { stream << ' ' }
  stream << "create: #{@create}\n"

  # modify
  indent.times { stream << ' ' }
  stream << "modify: #{!@modify.nil? ? @modify : '<unset>'}\n"

  # access
  indent.times { stream << ' ' }
  stream << "access: #{!@access.nil? ? @access : '<unset>'}\n"

  nil
end

#updateObject



30
31
32
33
34
35
# File 'lib/rcl/timestamp.rb', line 30

def update
  update_modify
  update_access

  nil
end

#update_accessObject



24
25
26
27
28
# File 'lib/rcl/timestamp.rb', line 24

def update_access
  @access = Time.now

  nil
end

#update_modifyObject



18
19
20
21
22
# File 'lib/rcl/timestamp.rb', line 18

def update_modify
  @modify = Time.now

  nil
end