Class: Moodswings::Mood
- Inherits:
-
Object
- Object
- Moodswings::Mood
- Defined in:
- lib/moodswings/mood.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
Class Method Summary collapse
Instance Method Summary collapse
- #contents ⇒ Object
- #file ⇒ Object
-
#initialize(filepath) ⇒ Mood
constructor
A new instance of Mood.
- #load ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(filepath) ⇒ Mood
Returns a new instance of Mood.
11 12 13 |
# File 'lib/moodswings/mood.rb', line 11 def initialize(filepath) @filepath = filepath end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
5 6 7 |
# File 'lib/moodswings/mood.rb', line 5 def filepath @filepath end |
Class Method Details
Instance Method Details
#contents ⇒ Object
23 24 25 |
# File 'lib/moodswings/mood.rb', line 23 def contents @contents ||= file.read end |
#file ⇒ Object
19 20 21 |
# File 'lib/moodswings/mood.rb', line 19 def file @file ||= File.open File.(@filepath) end |
#load ⇒ Object
27 28 29 |
# File 'lib/moodswings/mood.rb', line 27 def load self.instance_eval(contents) end |
#name ⇒ Object
15 16 17 |
# File 'lib/moodswings/mood.rb', line 15 def name File.basename(@filepath) end |