Class: Evesync::IPC::Data::File

Inherits:
Object
  • Object
show all
Extended by:
Unhashable
Includes:
Hashable
Defined in:
lib/evesync/ipc/data/file.rb

Defined Under Namespace

Modules: Action

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Unhashable

from_hash

Methods included from Hashable

#to_hash

Constructor Details

#initialize(params) ⇒ File



20
21
22
23
24
25
26
# File 'lib/evesync/ipc/data/file.rb', line 20

def initialize(params)
  @name = params[:name].freeze
  @mode = params[:mode].freeze
  @action = parse_action(params[:action]).freeze
  @timestamp = params[:timestamp] || NTP.timestamp
  @content = params[:content] || IO.read(@name).freeze if ::File.exist? @name
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



18
19
20
# File 'lib/evesync/ipc/data/file.rb', line 18

def action
  @action
end

#contentObject (readonly)

The content of a file for remote call. Sends as

a plain text(?), no extra calls between machines.

TODO

* Think about binary data
* Encoding information
* Large file sending


43
44
45
# File 'lib/evesync/ipc/data/file.rb', line 43

def content
  @content
end

#modeObject (readonly)

Returns the value of attribute mode.



18
19
20
# File 'lib/evesync/ipc/data/file.rb', line 18

def mode
  @mode
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/evesync/ipc/data/file.rb', line 18

def name
  @name
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



18
19
20
# File 'lib/evesync/ipc/data/file.rb', line 18

def timestamp
  @timestamp
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/evesync/ipc/data/file.rb', line 28

def ==(other)
  (@name == other.name) &&
    (@action == other.action) &&
    (@mode == other.mode)
  # timestamps may differ
  # conten comparing may cost too much
end