Class: ThemeCheck::AssetFile

Inherits:
Object
  • Object
show all
Defined in:
lib/theme_check/asset_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(relative_path, storage) ⇒ AssetFile

Returns a new instance of AssetFile.



7
8
9
10
11
12
# File 'lib/theme_check/asset_file.rb', line 7

def initialize(relative_path, storage)
  @relative_path = relative_path
  @storage = storage
  @loaded = false
  @content = nil
end

Instance Method Details

#contentObject



22
23
24
# File 'lib/theme_check/asset_file.rb', line 22

def content
  @content ||= @storage.read(@relative_path)
end

#gzipped_sizeObject



26
27
28
# File 'lib/theme_check/asset_file.rb', line 26

def gzipped_size
  @gzipped_size ||= Zlib.gzip(content).bytesize
end

#nameObject



30
31
32
# File 'lib/theme_check/asset_file.rb', line 30

def name
  relative_path.to_s
end

#pathObject



14
15
16
# File 'lib/theme_check/asset_file.rb', line 14

def path
  @storage.path(@relative_path)
end

#relative_pathObject



18
19
20
# File 'lib/theme_check/asset_file.rb', line 18

def relative_path
  @relative_pathname ||= Pathname.new(@relative_path)
end