Class: Unitylock::Server::Entity::UnityFile

Inherits:
Struct
  • Object
show all
Defined in:
lib/unitylock/server/entity/unityfile.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



6
7
8
# File 'lib/unitylock/server/entity/unityfile.rb', line 6

def file
  @file
end

#updated_atObject

Returns the value of attribute updated_at

Returns:

  • (Object)

    the current value of updated_at



6
7
8
# File 'lib/unitylock/server/entity/unityfile.rb', line 6

def updated_at
  @updated_at
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



6
7
8
# File 'lib/unitylock/server/entity/unityfile.rb', line 6

def user
  @user
end

Class Method Details

.create(hash) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/unitylock/server/entity/unityfile.rb', line 25

def create(hash)
  unityfile = UnityFile.new
  default_values = { updated_at: Time.now }
  default_values.merge(hash).each do |key,value|
    unityfile[key] = value
  end

  unityfile
end

.json_create(o) ⇒ Object



21
22
23
# File 'lib/unitylock/server/entity/unityfile.rb', line 21

def json_create(o)
  new(*o['v'])
end

Instance Method Details

#to_hashObject



12
13
14
15
16
17
18
# File 'lib/unitylock/server/entity/unityfile.rb', line 12

def to_hash
  {
    user: self.user,
    file: self.file,
    updated_at: self.updated_at.strftime("%Y-%m-%d %H:%M:%S")
  }
end

#updateObject



7
8
9
10
# File 'lib/unitylock/server/entity/unityfile.rb', line 7

def update
  self.updated_at = Time.now
  self
end