Class: Soy::File
- Inherits:
-
Object
- Object
- Soy::File
- Defined in:
- lib/soy/file.rb
Overview
Utility class for taking a path to a file and determining what its capabilities are within Soy
Instance Method Summary collapse
- #html? ⇒ Boolean
-
#initialize(file_path) ⇒ File
constructor
A new instance of File.
- #markdown? ⇒ Boolean
- #read ⇒ Object
- #render_with_erb? ⇒ Boolean
- #rendered_name ⇒ Object
Constructor Details
#initialize(file_path) ⇒ File
Returns a new instance of File.
7 8 9 |
# File 'lib/soy/file.rb', line 7 def initialize(file_path) @file_path = file_path end |
Instance Method Details
#html? ⇒ Boolean
28 29 30 |
# File 'lib/soy/file.rb', line 28 def html? @file_path =~ /.html/ end |
#markdown? ⇒ Boolean
24 25 26 |
# File 'lib/soy/file.rb', line 24 def markdown? @file_path =~ /.(md|markdown)/ end |
#read ⇒ Object
11 12 13 |
# File 'lib/soy/file.rb', line 11 def read ::File.read(@file_path) end |
#render_with_erb? ⇒ Boolean
20 21 22 |
# File 'lib/soy/file.rb', line 20 def render_with_erb? @file_path =~ /.erb$/ || markdown? || html? end |
#rendered_name ⇒ Object
15 16 17 18 |
# File 'lib/soy/file.rb', line 15 def rendered_name = @file_path.split("/").last.split(".").first "#{bare_name}.html" end |