Class: ImageKiIo::ActiveStorage::IKFile

Inherits:
Object
  • Object
show all
Defined in:
lib/active_storage/service/ik_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ IKFile

Returns a new instance of IKFile.



6
7
8
9
# File 'lib/active_storage/service/ik_file.rb', line 6

def initialize(identifier)
  @identifier = identifier
  @imagekit = ImageKitIo.client
end

Instance Attribute Details

#identifierObject

Returns the value of attribute identifier.



4
5
6
# File 'lib/active_storage/service/ik_file.rb', line 4

def identifier
  @identifier
end

Instance Method Details

#ai_tagsObject



70
71
72
# File 'lib/active_storage/service/ik_file.rb', line 70

def ai_tags
  identifier['AITags']
end

#alpha?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/active_storage/service/ik_file.rb', line 86

def alpha?
  identifier['hasAlpha']
end

#created_atObject



98
99
100
# File 'lib/active_storage/service/ik_file.rb', line 98

def created_at
  identifier['createdAt']
end

#custom_coordinatesObject



78
79
80
# File 'lib/active_storage/service/ik_file.rb', line 78

def custom_coordinates
  identifier['customCoordinates']
end

#custom_metadataObject



90
91
92
# File 'lib/active_storage/service/ik_file.rb', line 90

def 
  identifier['customMetadata']
end

#deleteObject



15
16
17
18
19
20
21
# File 'lib/active_storage/service/ik_file.rb', line 15

def delete
  begin
    @imagekit.delete_file(file_id: file_id)
  rescue
    file_id
  end
end

#embedded_metadataObject



94
95
96
# File 'lib/active_storage/service/ik_file.rb', line 94

def 
  identifier['embeddedMetadata']
end

#exist?Boolean

Returns:

  • (Boolean)


55
56
57
58
59
60
# File 'lib/active_storage/service/ik_file.rb', line 55

def exist?
  details = @imagekit.get_file_details(file_id: file_id)
  return false if details[:error].present?

  true
end

#extension_statusObject



106
107
108
# File 'lib/active_storage/service/ik_file.rb', line 106

def extension_status
  identifier['extensionStatus']
end

#file_idObject



51
52
53
# File 'lib/active_storage/service/ik_file.rb', line 51

def file_id
  identifier['fileId']
end

#file_typeObject



23
24
25
# File 'lib/active_storage/service/ik_file.rb', line 23

def file_type
  identifier['fileType']
end

#filenameObject



31
32
33
# File 'lib/active_storage/service/ik_file.rb', line 31

def filename
  identifier['name']
end

#heightObject



43
44
45
# File 'lib/active_storage/service/ik_file.rb', line 43

def height
  identifier['height']
end

#is_private?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/active_storage/service/ik_file.rb', line 74

def is_private?
  identifier['isPrivateFile']
end

#mimeObject



82
83
84
# File 'lib/active_storage/service/ik_file.rb', line 82

def mime
  identifier['mime']
end

#pathObject



39
40
41
# File 'lib/active_storage/service/ik_file.rb', line 39

def path
  identifier['filePath']
end

#sizeObject



35
36
37
# File 'lib/active_storage/service/ik_file.rb', line 35

def size
  identifier['size']
end

#tagsObject



66
67
68
# File 'lib/active_storage/service/ik_file.rb', line 66

def tags
  identifier['tags']
end

#thumbnail_urlObject



27
28
29
# File 'lib/active_storage/service/ik_file.rb', line 27

def thumbnail_url
  identifier['thumbnail']
end

#transformationObject



110
111
112
# File 'lib/active_storage/service/ik_file.rb', line 110

def transformation
  identifier['transformation']
end

#typeObject



62
63
64
# File 'lib/active_storage/service/ik_file.rb', line 62

def type
  identifier['type']
end

#updated_atObject



102
103
104
# File 'lib/active_storage/service/ik_file.rb', line 102

def updated_at
  identifier['updatedAt']
end

#urlObject



11
12
13
# File 'lib/active_storage/service/ik_file.rb', line 11

def url
  identifier['url']
end

#widthObject



47
48
49
# File 'lib/active_storage/service/ik_file.rb', line 47

def width
  identifier['width']
end