Class: WLang::Source
- Inherits:
-
Object
- Object
- WLang::Source
- Defined in:
- lib/wlang/source.rb,
lib/wlang/source/front_matter.rb
Direct Known Subclasses
Defined Under Namespace
Classes: FrontMatter
Instance Attribute Summary collapse
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(subject, template = nil) ⇒ Source
constructor
A new instance of Source.
- #locals ⇒ Object
- #path ⇒ Object (also: #to_path)
- #raw_content ⇒ Object
- #template_content ⇒ Object
- #to_str ⇒ Object (also: #to_s)
- #with_front_matter(enabled = true) ⇒ Object
Constructor Details
#initialize(subject, template = nil) ⇒ Source
Returns a new instance of Source.
7 8 9 10 11 |
# File 'lib/wlang/source.rb', line 7 def initialize(subject, template = nil) @subject = subject @template = template @locals = {} end |
Instance Attribute Details
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
4 5 6 |
# File 'lib/wlang/source.rb', line 4 def subject @subject end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
5 6 7 |
# File 'lib/wlang/source.rb', line 5 def template @template end |
Instance Method Details
#locals ⇒ Object
18 19 20 |
# File 'lib/wlang/source.rb', line 18 def locals @locals end |
#path ⇒ Object Also known as: to_path
13 14 15 |
# File 'lib/wlang/source.rb', line 13 def path find_on_subject(:path, :to_path) end |
#raw_content ⇒ Object
22 23 24 25 26 |
# File 'lib/wlang/source.rb', line 22 def raw_content find_on_subject(:read, :to_str){ raise ArgumentError, "Invalid template source `#{subject}`" } end |
#template_content ⇒ Object
28 29 30 |
# File 'lib/wlang/source.rb', line 28 def template_content raw_content end |
#to_str ⇒ Object Also known as: to_s
32 33 34 |
# File 'lib/wlang/source.rb', line 32 def to_str template_content end |
#with_front_matter(enabled = true) ⇒ Object
37 38 39 |
# File 'lib/wlang/source.rb', line 37 def with_front_matter(enabled = true) enabled ? FrontMatter.new(self, template) : self end |