Class: PogoPlug::File

Inherits:
Object
  • Object
show all
Includes:
HashInitializer
Defined in:
lib/pogoplug/file.rb

Defined Under Namespace

Modules: Type

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HashInitializer

#initialize

Instance Attribute Details

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/pogoplug/file.rb', line 3

def id
  @id
end

#mimetypeObject

Returns the value of attribute mimetype.



3
4
5
# File 'lib/pogoplug/file.rb', line 3

def mimetype
  @mimetype
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/pogoplug/file.rb', line 3

def name
  @name
end

#parent_idObject

Returns the value of attribute parent_id.



3
4
5
# File 'lib/pogoplug/file.rb', line 3

def parent_id
  @parent_id
end

#sizeObject

Returns the value of attribute size.



3
4
5
# File 'lib/pogoplug/file.rb', line 3

def size
  @size
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/pogoplug/file.rb', line 3

def type
  @type
end

Class Method Details

.from_json(json) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/pogoplug/file.rb', line 26

def self.from_json(json)
  File.new(
    name: json['name'],
    id: json['fileid'],
    type: json['type'].to_i,
    mimetype: json['mimetype'],
    parent_id: json['parentid'],
    size: json['size'].to_i
  )
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/pogoplug/file.rb', line 14

def directory?
  @type == File::Type::DIRECTORY
end

#file?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/pogoplug/file.rb', line 18

def file?
  @type == File::Type::FILE
end