Class: Fewer::Engines::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/fewer/engines/abstract.rb

Direct Known Subclasses

Css, Js, JsMin, Less

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, names) ⇒ Abstract

Returns a new instance of Abstract.



6
7
8
9
10
# File 'lib/fewer/engines/abstract.rb', line 6

def initialize(root, names)
  @root = root
  @names = names
  check_paths!
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



4
5
6
# File 'lib/fewer/engines/abstract.rb', line 4

def names
  @names
end

#rootObject (readonly)

Returns the value of attribute root.



4
5
6
# File 'lib/fewer/engines/abstract.rb', line 4

def root
  @root
end

Instance Method Details

#content_typeObject



12
13
14
# File 'lib/fewer/engines/abstract.rb', line 12

def content_type
  'text/plain'
end

#extensionObject



16
17
# File 'lib/fewer/engines/abstract.rb', line 16

def extension
end

#mtimeObject



19
20
21
22
23
# File 'lib/fewer/engines/abstract.rb', line 19

def mtime
  paths.map { |path|
    File.mtime(path).to_i
  }.sort.last
end

#pathsObject



25
26
27
28
29
# File 'lib/fewer/engines/abstract.rb', line 25

def paths
  names.map { |name|
    File.join(root, "#{File.basename(name.to_s)}#{extension}")
  }
end

#readObject



31
32
33
34
35
# File 'lib/fewer/engines/abstract.rb', line 31

def read
  paths.map { |path|
    File.read(path)
  }.join("\n")
end