Class: Fewer::Engines::Abstract
- Inherits:
-
Object
- Object
- Fewer::Engines::Abstract
- Defined in:
- lib/fewer/engines/abstract.rb
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #content_type ⇒ Object
- #extension ⇒ Object
-
#initialize(root, names) ⇒ Abstract
constructor
A new instance of Abstract.
- #mtime ⇒ Object
- #paths ⇒ Object
- #read ⇒ Object
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
#names ⇒ Object (readonly)
Returns the value of attribute names.
4 5 6 |
# File 'lib/fewer/engines/abstract.rb', line 4 def names @names end |
#root ⇒ Object (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_type ⇒ Object
12 13 14 |
# File 'lib/fewer/engines/abstract.rb', line 12 def content_type 'text/plain' end |
#extension ⇒ Object
16 17 |
# File 'lib/fewer/engines/abstract.rb', line 16 def extension end |
#mtime ⇒ Object
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 |
#paths ⇒ Object
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 |
#read ⇒ Object
31 32 33 34 35 |
# File 'lib/fewer/engines/abstract.rb', line 31 def read paths.map { |path| File.read(path) }.join("\n") end |