Class: GeneratedAssets::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/generated-assets/entry.rb

Constant Summary collapse

DEFAULT_PROC =
Proc.new { '' }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logical_path, callback, options = {}) ⇒ Entry

Returns a new instance of Entry.



11
12
13
14
15
# File 'lib/generated-assets/entry.rb', line 11

def initialize(logical_path, callback, options = {})
  @logical_path = logical_path
  @callback = callback || DEFAULT_PROC
  @options = options
end

Instance Attribute Details

#callbackObject (readonly)

Returns the value of attribute callback.



9
10
11
# File 'lib/generated-assets/entry.rb', line 9

def callback
  @callback
end

#logical_pathObject (readonly)

Returns the value of attribute logical_path.



9
10
11
# File 'lib/generated-assets/entry.rb', line 9

def logical_path
  @logical_path
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/generated-assets/entry.rb', line 9

def options
  @options
end

Instance Method Details

#precompile?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/generated-assets/entry.rb', line 17

def precompile?
  @options.fetch(:precompile, false)
end

#write_to(prefix) ⇒ Object



21
22
23
24
25
# File 'lib/generated-assets/entry.rb', line 21

def write_to(prefix)
  path = File.join(prefix, logical_path)
  FileUtils.mkdir_p(File.dirname(path))
  File.binwrite(path, callback.call)
end