Class: Fewer::Engines::Abstract
- Inherits:
-
Object
- Object
- Fewer::Engines::Abstract
- Defined in:
- lib/fewer/engines/abstract.rb
Constant Summary collapse
- SANITISE_REGEXP =
/^#{File::Separator}|\.\.#{File::Separator}/
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #content_type ⇒ Object
- #encoded ⇒ Object
- #extension ⇒ Object
-
#initialize(root, names, options = {}) ⇒ Abstract
constructor
A new instance of Abstract.
- #mtime ⇒ Object
- #paths ⇒ Object
- #read ⇒ Object
Constructor Details
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
6 7 8 |
# File 'lib/fewer/engines/abstract.rb', line 6 def names @names end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/fewer/engines/abstract.rb', line 6 def @options end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/fewer/engines/abstract.rb', line 6 def root @root end |
Instance Method Details
#content_type ⇒ Object
16 17 18 |
# File 'lib/fewer/engines/abstract.rb', line 16 def content_type 'text/plain' end |
#encoded ⇒ Object
20 21 22 |
# File 'lib/fewer/engines/abstract.rb', line 20 def encoded Serializer.encode(names) end |
#extension ⇒ Object
24 25 |
# File 'lib/fewer/engines/abstract.rb', line 24 def extension end |
#mtime ⇒ Object
27 28 29 30 31 |
# File 'lib/fewer/engines/abstract.rb', line 27 def mtime paths.map { |path| File.mtime(path) }.max end |
#paths ⇒ Object
33 34 35 36 37 |
# File 'lib/fewer/engines/abstract.rb', line 33 def paths @paths ||= names.map { |name| File.join(root, "#{name}#{extension}") } end |
#read ⇒ Object
39 40 41 42 43 |
# File 'lib/fewer/engines/abstract.rb', line 39 def read paths.map { |path| File.read(path) }.join("\n") end |