Class: Torba::ImportList

Inherits:
Object
  • Object
show all
Defined in:
lib/torba/import_list.rb

Overview

Represents a list of assets to be imported from a remote source.

Since:

  • 0.1.0

Defined Under Namespace

Classes: Asset

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assets) ⇒ ImportList

Returns a new instance of ImportList

Since:

  • 0.1.0



17
18
19
# File 'lib/torba/import_list.rb', line 17

def initialize(assets)
  @assets = assets
end

Instance Attribute Details

#assetsArray<Asset> (readonly)

Returns full list of assets to be imported.

Returns:

  • (Array<Asset>)

    full list of assets to be imported.

Since:

  • 0.1.0



15
16
17
# File 'lib/torba/import_list.rb', line 15

def assets
  @assets
end

Instance Method Details

#css_assetsArray<Asset>

Returns list of stylesheets to be imported.

Returns:

  • (Array<Asset>)

    list of stylesheets to be imported.

Since:

  • 0.1.0



29
30
31
# File 'lib/torba/import_list.rb', line 29

def css_assets
  assets.find_all { |asset| asset.css? }
end

#find_by_absolute_path(path) ⇒ Asset

Returns asset with given path.

Parameters:

  • path (String)

    absolute path of an asset.

Returns:

  • (Asset)

    asset with given path.

Raises:

Since:

  • 0.1.0



24
25
26
# File 'lib/torba/import_list.rb', line 24

def find_by_absolute_path(path)
  assets.find { |asset| asset.absolute_path == path } || raise(Errors::AssetNotFound.new(path))
end

#non_css_assetsArray<Asset>

Returns list of assets to be imported except stylesheets.

Returns:

  • (Array<Asset>)

    list of assets to be imported except stylesheets.

Since:

  • 0.1.0



34
35
36
# File 'lib/torba/import_list.rb', line 34

def non_css_assets
  assets.find_all { |asset| !asset.css? }
end