Class: SemiStatic::Base
- Inherits:
-
Object
- Object
- SemiStatic::Base
- Defined in:
- lib/semi-static/base.rb
Overview
Base is a single source file and its associated metadata. Base loads itself from the source file and strips off and parses the metadata in the file’s header.
Instance Attribute Summary collapse
-
#full_source_path ⇒ Object
readonly
The absolute path to the source file.
-
#site ⇒ Object
readonly
The associated Site object.
-
#source_content ⇒ Object
readonly
The source file’s contents.
-
#source_ext ⇒ Object
readonly
The source file’s extension.
-
#source_metadata ⇒ Object
readonly
The metadata found in the file’s header.
-
#source_path ⇒ Object
readonly
The relative path to the source file.
Instance Method Summary collapse
-
#initialize(site, path) ⇒ Base
constructor
Initializes a new Base.
-
#source_mtime ⇒ Object
Get the modification time of the source file.
Constructor Details
#initialize(site, path) ⇒ Base
Initializes a new Base
site-
The Site object we belong to
path-
The relative path to the source file
35 36 37 38 39 40 41 42 43 |
# File 'lib/semi-static/base.rb', line 35 def initialize(site, path) @site = site @source_path = path @source_ext = File.extname(source_path) @full_source_path = File.(source_path) @metadata = [] load end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (protected)
:nodoc:
64 65 66 67 68 69 70 71 |
# File 'lib/semi-static/base.rb', line 64 def method_missing(method, *args) #:nodoc: name = method.to_sym if @metadata.include?(name) return [name] else super end end |
Instance Attribute Details
#full_source_path ⇒ Object (readonly)
The absolute path to the source file
28 29 30 |
# File 'lib/semi-static/base.rb', line 28 def full_source_path @full_source_path end |
#site ⇒ Object (readonly)
The associated Site object
8 9 10 |
# File 'lib/semi-static/base.rb', line 8 def site @site end |
#source_content ⇒ Object (readonly)
The source file’s contents
20 21 22 |
# File 'lib/semi-static/base.rb', line 20 def source_content @source_content end |
#source_ext ⇒ Object (readonly)
The source file’s extension
16 17 18 |
# File 'lib/semi-static/base.rb', line 16 def source_ext @source_ext end |
#source_metadata ⇒ Object (readonly)
The metadata found in the file’s header
24 25 26 |
# File 'lib/semi-static/base.rb', line 24 def @source_metadata end |
#source_path ⇒ Object (readonly)
The relative path to the source file
12 13 14 |
# File 'lib/semi-static/base.rb', line 12 def source_path @source_path end |
Instance Method Details
#source_mtime ⇒ Object
Get the modification time of the source file.
47 48 49 |
# File 'lib/semi-static/base.rb', line 47 def source_mtime File.mtime(@full_source_path) end |