Class: Diary::Snippet
- Inherits:
-
Object
- Object
- Diary::Snippet
- Defined in:
- lib/diary/snippet.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(name) ⇒ Snippet
constructor
A new instance of Snippet.
Constructor Details
#initialize(name) ⇒ Snippet
Returns a new instance of Snippet.
5 6 7 |
# File 'lib/diary/snippet.rb', line 5 def initialize(name) @path = File.join("snippets", "#{name}.html") end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/diary/snippet.rb', line 3 def path @path end |
Instance Method Details
#content ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/diary/snippet.rb', line 9 def content unless @content File.open(path, 'r') do |file| @content ||= file.read end end @content end |