Class: DailyLog::Pathname
- Inherits:
-
Object
- Object
- DailyLog::Pathname
- Extended by:
- Forwardable
- Defined in:
- lib/daily_log/pathname.rb
Overview
The pathname for an Entry file on a given Day
Constant Summary collapse
- DEFAULT_DIRNAME =
The default name for the dir where entries are stored.
".daily_logs"- FORMAT =
The default format for entries
"md"
Class Attribute Summary collapse
-
.dirname ⇒ Object
The dirname where entries are stored.
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
The Date we’re caluclating the Pathname for.
Instance Method Summary collapse
-
#dirname ⇒ Object
The name of the directory where the Entry will live.
-
#initialize(date) ⇒ Pathname
constructor
Create a new Pathname.
-
#to_path ⇒ Object
(also: #to_s)
The Pathname as a path string Returns String.
Constructor Details
#initialize(date) ⇒ Pathname
Create a new Pathname
date - The Date we’re creating a Pathname for
46 47 48 |
# File 'lib/daily_log/pathname.rb', line 46 def initialize(date) @date = date end |
Class Attribute Details
.dirname ⇒ Object
The dirname where entries are stored
Returns String
37 38 39 |
# File 'lib/daily_log/pathname.rb', line 37 def dirname @dirname || DEFAULT_DIRNAME end |
Instance Attribute Details
#date ⇒ Object (readonly)
The Date we’re caluclating the Pathname for
23 24 25 |
# File 'lib/daily_log/pathname.rb', line 23 def date @date end |
Instance Method Details
#dirname ⇒ Object
The name of the directory where the Entry will live
Returns String
61 62 63 |
# File 'lib/daily_log/pathname.rb', line 61 def dirname File.join self.class.dirname, year.zero_pad, month.zero_pad end |
#to_path ⇒ Object Also known as: to_s
The Pathname as a path string Returns String
52 53 54 |
# File 'lib/daily_log/pathname.rb', line 52 def to_path File.join(dirname, "#{day.zero_pad}.#{FORMAT}") end |