Class: DailyLog::Pathname

Inherits:
Object
  • Object
show all
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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

.dirnameObject

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

#dateObject (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

#dirnameObject

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_pathObject 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