Class: Soy::File

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (Boolean)


28
29
30
# File 'lib/soy/file.rb', line 28

def html?
  @file_path =~ /.html/
end

#markdown?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/soy/file.rb', line 24

def markdown?
  @file_path =~ /.(md|markdown)/
end

#readObject



11
12
13
# File 'lib/soy/file.rb', line 11

def read
  ::File.read(@file_path)
end

#render_with_erb?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/soy/file.rb', line 20

def render_with_erb?
  @file_path =~ /.erb$/ || markdown? || html?
end

#rendered_nameObject



15
16
17
18
# File 'lib/soy/file.rb', line 15

def rendered_name
  bare_name = @file_path.split("/").last.split(".").first
  "#{bare_name}.html"
end